1. 程式人生 > >SenseTime Ace Coder Challenge 暨 商湯在線編程挑戰賽* B. 我覺得海星

SenseTime Ace Coder Challenge 暨 商湯在線編程挑戰賽* B. 我覺得海星

tdi clas 異或 push space names while () HA

res[i][j]:i->{x1,x2,x3...}->j 的集合的異或值

c[i][j]:i->{x1,x2,x3...}->j 的集合中元素個數

flag[i][j][k]:k點是否在i->{x1,x2,x3...}->j 的集合中

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include
<map> #include<cmath> #include<set> #include<stack> #define ll long long #define pb push_back #define max(x,y) ((x)>(y)?(x):(y)) #define min(x,y) ((x)>(y)?(y):(x)) #define cls(name,x) memset(name,x,sizeof(name)) #define fs first #define sc second #define mp make_pair #define
L(x) (1<<x) #define next Next #define index Index using namespace std; const int inf=1e9+10; const ll llinf=1e17+10; const int maxn=2e2+10; const int maxm=1e6+10; const int maxk=1e5+10; const int mod=1e9+7; int n; char mapp[maxn][maxn]; int res[maxn][maxn]; int c[maxn][maxn]; bool flag[maxn][maxn][maxn];
int ans; int main() { //freopen("in.txt","r",stdin); int T,cas=1; scanf("%d",&T); while (T--) { ans=0; scanf("%d",&n); cls(c,0); cls(flag,0); cls(res,0); for(int i=0;i<n;i++) scanf("%s",mapp[i]); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) for(int k=1;k<=n;k++) if(i!=j&&i!=k&&j!=k&&mapp[i-1][k-1]==1&&mapp[j-1][k-1]==1) { flag[i][j][k]=1; res[i][j]^=k; c[i][j]++; } for(int i=1;i<=n;i++) for(int k1=1;k1<=n;k1++) for(int k2=1;k2<=n;k2++) { if(i==k1||i==k2||k1==k2) continue; if(mapp[k1-1][k2-1]!=1) continue; int realres1=res[i][k1],realres2=res[i][k2]; int realc1=c[i][k1],realc2=c[i][k2]; if(flag[i][k1][k2]) { realc1--; realres1^=k2; } if(flag[i][k2][k1]) { realc2--; realres2^=k1; } if(realc1>0&&realc2>0) { if(realc1>=2||realc2>=2) ans=1; if(realc1==1&&realc2==1&&(realres1^realres2)!=0) ans=1; } } printf("Case #%d: %s\n",cas++,ans?"Starfish!":"Walk Walk"); } return 0; }

SenseTime Ace Coder Challenge 暨 商湯在線編程挑戰賽* B. 我覺得海星