Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ttt
//------------------------------------------------------------------------------------------------------------------------------- //g++ 7.4.0 //Base File //------------------------------------------------------------------------------------------------------------------------------- /* ᕙ( • ‿ • )ᕗ Dire Wolf ->Manan's Code Pad<- Patience Bravery */ //------------------------------------------------------------------------------------------------------------------------------- // ¯\_(ツ)_/¯ <Code> //------------------------------------------------------------------------------------------------------------------------------- #include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; bool win(char c, vector<vector<char>>&ttt) { // bool p1,p2,p3,p4; for(int i=0; i<3; i++) { if(ttt[0][i]==c and ttt[1][i]==c and ttt[2][i]==c) return true; } for(int i=0; i<3; i++) { if(ttt[i][0]==c and ttt[i][1]==c and ttt[i][2]==c) return true; } if(ttt[0][0]==c and ttt[1][1]==c and ttt[2][2]==c) return true; if(ttt[2][0]==c and ttt[1][1]==c and ttt[0][2]==c) return true; return false; } int main() { //std::cout << "Hello, world!\n"; ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin>>t; while(t--){ vector<vector<char>> ttt(3, vector<char>(3)); int cnto=0; int cntx=0; int cnt_=0; for(int i=0; i<3; i++) { for(int j=0; j<3; j++) { cin>>ttt[i][j]; if(ttt[i][j]=='X') cntx++; if(ttt[i][j]=='O') cnto++; if(ttt[i][j]=='_') cnt_++; } } if(cnto==4 and cntx==5) cout<<1<<endl; else if(cnto==cntx or cnto+1==cntx) { //cout<<cntx<<cnto; // cout<<1000; int flag=0; bool xwin=false,owin=false; if(cntx==3) { //cout<<45; if(win('X',ttt)) xwin=true; } else if(cntx==4) { if(win('X', ttt)) xwin=true; } if(cnto==3){ if(win('O',ttt)) owin=true; } //cout<<xwin<<owin; if(xwin and owin) { // cout<<4040; cout<<3<<endl; flag++; } else if(xwin) { //cout<<444; cout<<1<<endl; flag++; } else if( owin) { cout<<1<<endl; flag++; } if(flag==0) cout<<2<<endl; } else cout<<3<<endl; } return 0; } //------------------------------------------------------------------------------------------------------------------------------- // End //-------------------------------------------------------------------------------------------------------------------------------
run
|
edit
|
history
|
help
0
BubDoubArray2
variadic pointer to function template
binary
DayTempEnum
Permute
Callback
dsu on tree (http://codeforces.com/contest/208/problem/E)
PascalTriangle
return reference (gcc)
Prime Factor