Ideas:
Simulation.
Code:
#include <bits/stdc++.h>using namespacestd;#definell Long Long#definePB Push_back#defineMem (A, B) memset (A,b,sizeof (a))intdir[4][2]={-1,0,1,0,0,-1,0,1};intmp[5][5];intbelong[ the];intInx,iny;BOOL is(intXintYintXxintyy) { if(X==inx&&y==iny)return true; if(Xx==inx&&yy==iny)return true; return false;}intMain () {Ios::sync_with_stdio (false); Cin.tie (0); intcs=0, N,q,p; while(cin>>N) { for(intI=1; i<=4; i++){ for(intj=1; j<=4; j + +) mp[i][j]=0; } mp[1][1]= One; mp[1][2]=Ten; mp[1][3]=9; mp[1][4]=8; mp[2][1]= A; mp[2][4]=7; mp[3][1]=1; mp[3][4]=6; mp[4][1]=2; mp[4][2]=3; mp[4][3]=4; mp[4][4]=5; for(intI=1; i<=6; i++) belong[i]=1; for(intI=7; i<= A; i++) belong[i]=2; while(n--) {cin>>q>>p; for(intI=1; i<=4; i++){ BOOLf=false; for(intj=1; j<=4; j + +){ if(mp[i][j]==3) {Mp[i][j]=0; F=true; Inx=i+dir[p-1][0]; Iny=j+dir[p-1][1]; //cout<<inx<< "" <<iny<<endl;mp[inx][iny]=Q; Break; } } if(f) Break; } for(intI=1; i<=4; i++){ if( isI1I2) &&mp[i][1]>0&&belong[mp[i][1]]==belong[mp[i][2]]&&belong[mp[i][2]]!=belong[mp[i][3]]&&mp[i][4]==0) mp[i][3]=0; if( isI2I3) &&mp[i][2]>0&&belong[mp[i][2]]==belong[mp[i][3]]&&belong[mp[i][3]]!=belong[mp[i][4]]&&mp[i][1]==0) mp[i][4]=0; if( isI2I3) &&mp[i][2]>0&&belong[mp[i][2]]==belong[mp[i][3]]&&belong[mp[i][2]]!=belong[mp[i][1]]&&mp[i][4]==0) mp[i][1]=0; if( isI4I3) &&mp[i][3]>0&&belong[mp[i][3]]==belong[mp[i][4]]&&belong[mp[i][3]]!=belong[mp[i][2]]&&mp[i][1]==0) mp[i][2]=0; } for(intI=1; i<=4; i++){ if( is(1I2, i) &&mp[1][i]>0&&belong[mp[1][i]]==belong[mp[2][i]]&&belong[mp[2][i]]!=belong[mp[3][i]]&&mp[4][i]==0) mp[3][i]=0; if( is(2I3, i) &&mp[2][i]>0&&belong[mp[2][i]]==belong[mp[3][i]]&&belong[mp[3][i]]!=belong[mp[4][i]]&&mp[1][i]==0) mp[4][i]=0; if( is(2I3, i) &&mp[2][i]>0&&belong[mp[2][i]]==belong[mp[3][i]]&&belong[mp[2][i]]!=belong[mp[1][i]]&&mp[4][i]==0) mp[1][i]=0; if( is(4I3, i) &&mp[3][i]>0&&belong[mp[3][i]]==belong[mp[4][i]]&&belong[mp[3][i]]!=belong[mp[2][i]]&&mp[1][i]==0) mp[2][i]=0; } /*for (int i=1;i<=4;i++) {for (int j=1;j<=4;j++) {COUT<<SETW (3) <<mp[i][j]; } cout<<endl; }*/} cout<<"#Case"<<++cs<<":"<<Endl; for(intI=1; i<=4; i++){ for(intj=1; j<=4; j + +) {cout<<SETW (3) <<Mp[i][j]; } cout<<Endl; } } return 0;}
2018 National multi-school algorithm winter training Camp practice Competition (first game) C six sub-punch