1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| #include <bits/stdc++.h> #define N 105 #define mod 1000000007 #define FOR(i,n) for(int i=0;i<n;i++) #define ios ios::sync_with_stdio(0) using namespace std; char name[N],line[N][10]; pair<int,int> mp[N][N];
bool check(int people,int number){ int r = mp[people][number].first,c = mp[people][number].second; line[people][r]+=1; line[people][c+4]+=1; if(line[people][r]==4)return 1; if(line[people][c+4]==4)return 1; if(r+c==3){ line[people][8]+=1; if(line[people][8]==4)return 1; } if(r==c){ line[people][9]+=1; if(line[people][9]==4)return 1; } return 0; }
signed main(){ ios; int n; char cha; cin>>cha>>n; memset(line,0,sizeof(line)); for(int i=0;i<n;i++){ cin>>name[i]; for(int j=0;j<16;j++){ int temp;cin>>temp; mp[i][temp].first = j/4; mp[i][temp].second = j%4; } } int cnt = 16,flag = 0; cin>>cha; while(cnt--){ int temp;cin>>temp; cout<<temp<<" "; for(int i=0;i<n;i++){ if(check(i,temp)){ cout<<name[i]<<" "; flag = 1; } } if(flag)break; } }
|