链接:https://nanti.jisuanke.com/acm?kw=ACM-ICPC%202017%20Asia%20Qingdao
B(模拟)
像#一样3个一个字母就输出那个字母
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char ans;
string a[3];
int main(){
int t,ok;
scanf("%d",&t);
while(t--){
//getchar();
for(int i = 0;i<3;++i){
cin>>a[i];
}
ok = 0;
for(int i = 0;i<3;++i){
for(int j = 0;j<3;++j){
if(i != 0&&j != 0)
continue;
if(i == 0&&j == 0){
if(a[i][j] == a[i+1][j+1] && a[i+1][j+1]== a[i+2][j+2] && a[i][j] != '.'){
// cout<<"1\n";
ok = 1;
ans = a[i][j];
break;
}
}
if(i == 0&&j == 2){
if(a[0][2] == a[1][1] &&a[1][1]== a[2][0] && a[i][j] != '.'){
// cout<<"2\n";
ok = 1;
ans = a[i][j];
break;
}
}
if(i == 0){
if(a[i][j] == a[i+1][j] &&a[i+1][j] == a[i+2][j] && a[i][j] != '.'){
// cout<<"3\n";
ok = 1;
ans = a[i][j];
break;
}
}
if(j == 0){
if(a[i][j] == a[i][j+1] &&a[i][j+1] == a[i][j+2] && a[i][j] != '.'){
// cout<<"4\n";`
ok = 1;
ans = a[i][j];
break;
}
}
}
if(ok == 1)
break;
}
if(ok == 1)
cout<<ans<<endl;
else
cout<<"ongoing\n";
}
return 0;
}
I The Squared Mosquito Coil
题意:画圈圈图
dfs
l = 0;
num = 1;
memset(visit, false, sizeof(visit));
cin >> n;
dfs(0, 0);//利用dfs走的结果把能走的位置标记为true
int i;
int j;
for(i = 0; i < n; i++)//利用visit数组输出
{
for(j = 0; j < n; j++)
{
if(visit[i][j])
{
cout << "#";
}
else
{
cout << " ";
}
}
cout << endl;
}
}
return 0;
}