知識
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們在追求其視覺表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營銷的便利,運(yùn)營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏壧峁┍憬莸闹С郑?
B. Putting Bricks in the Wall(思維)Codeforces Round
發(fā)表時(shí)間:2020-10-19
發(fā)布人:葵宇科技
瀏覽次數(shù):95
原題鏈接:https://codeforces.com/contest/1421/problem/B
測試樣例
input
3
4
S010
0001
1000
111F
3
S10
101
01F
5
S0101
00000
01111
11111
0001F
output
1
3 4
2
1 2
2 1
0
題意: 給定一個(gè) n × n n\times n n×n的迷宮,現(xiàn)在 P i n k Pink Pink在起點(diǎn) ( 1 , 1 ) (1,1) (1,1)處,終點(diǎn)在 ( n , n ) (n,n) (n,n)處, P i n k Pink Pink在開始游戲之前會(huì)選擇一個(gè)數(shù) 0 0 0或 1 1 1,迷宮的每個(gè)格子會(huì)存在一個(gè) 0 0 0或 1 1 1的數(shù)字,游戲規(guī)則為 P i n k Pink Pink只能走相鄰的且格子數(shù)為開始游戲前選擇的數(shù)的格子?,F(xiàn)在你最多有兩次機(jī)會(huì)可以改變元素值,問你怎樣才使得 P i n k Pink Pink不能走到終點(diǎn)。
解題思路: 這是一道思維題,不用想得很深,我們只需要知道 P i n k Pink Pink一開始走出起點(diǎn)的限制有兩個(gè)格子 ( 1 , 2 ) (1,2) (1,2)和(2,1),走到終點(diǎn)也有兩個(gè)格子限制 ( n ? 1 , n ) (n-1,n) (n?1,n)和 ( n , n ? 1 ) (n,n-1) (n,n?1)。那么只要使得這起點(diǎn)格子和終點(diǎn)格子起沖突即可。讓這兩組的格子元素值相反即可。 我們利用if判斷即可得出答案。注意所有情況的考慮。
AC代碼
/*
*郵箱:unique_powerhouse@qq.com
*blog:https://me.csdn.net/hzf0701
*注:文章若有任何問題請私信我或評論區(qū)留言,謝謝支持。
*
*/
#include<bits/stdc++.h> //POJ不支持
#define rep(i,a,n) for (int i=a;i<=n;i++)//i為循環(huán)變量,a為初始值,n為界限值,遞增
#define per(i,a,n) for (int i=a;i>=n;i--)//i為循環(huán)變量, a為初始值,n為界限值,遞減。
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define mp make_pair
using namespace std;
const int inf = 0x3f3f3f3f;//無窮大
const int maxn = 205;//最大值。
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
//*******************************分割線,以上為自定義代碼模板***************************************//
int t,n;
char graph[maxn][maxn];
int main(){
//freopen("in.txt", "r", stdin);//提交的時(shí)候要注釋掉
IOS;
while(cin>>t){
while(t--){
cin>>n;
rep(i,0,n-1){
cin>>graph[i];
}
char a1=graph[1][0],a2=graph[0][1],b1=graph[n-2][n-1],b2=graph[n-1][n-2];
if(a1!=a2){
if(b1!=b2){
cout<<2<<endl;
if(a1==b1){
cout<<"2 1"<<endl;
cout<<n<<" "<<n-1<<endl;
}
else{
cout<<"2 1"<<endl;
cout<<n-1<<" "<<n<<endl;
}
}
else{
if(a1==b1){
cout<<1<<endl;
cout<<"2 1"<<endl;
}
else{
cout<<1<<endl;
cout<<"1 2"<<endl;
}
}
}
else{
if(b1==b2){
if(b1==a1){
cout<<2<<endl;
cout<<"1 2"<<endl;
cout<<"2 1"<<endl;
}
else{
cout<<0<<endl;
}
continue;
}
if(b1==a1){
cout<<1<<endl;
cout<<n-1<<" "<<n<<endl;
}
else{
cout<<1<<endl;
cout<<n<<" "<<n-1<<endl;
}
}
}
}
return 0;
}
相關(guān)案例查看更多
相關(guān)閱讀
- 云南網(wǎng)站建設(shè)首頁
- 網(wǎng)站優(yōu)化
- 支付寶小程序被騙
- 云南建設(shè)廳網(wǎng)站
- 網(wǎng)頁制作
- 云南小程序設(shè)計(jì)
- 重慶網(wǎng)站建設(shè)公司
- 網(wǎng)站建設(shè)首選
- 百度小程序開發(fā)公司
- 手機(jī)網(wǎng)站建設(shè)
- 小程序開發(fā)
- 分銷系統(tǒng)
- 小程序生成海報(bào)
- 網(wǎng)站制作哪家好
- 網(wǎng)站建設(shè)電話
- 昆明做網(wǎng)站建設(shè)的公司排名
- 報(bào)廢車
- 網(wǎng)站維護(hù)
- 安家微信小程序
- 北京小程序制作
- 汽車報(bào)廢系統(tǒng)
- 小程序分銷商城
- 網(wǎng)站排名
- 報(bào)廢車拆解管理系統(tǒng)
- 網(wǎng)站開發(fā)公司哪家好
- 汽車拆解管理系統(tǒng)
- 企業(yè)網(wǎng)站
- 海報(bào)插件
- 云南網(wǎng)站建設(shè)哪家好
- 百度推廣