Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ttt
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//------------------------------------------------------------------------------------------------------------------------------- //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 //-------------------------------------------------------------------------------------------------------------------------------
g++
1 XXX X_O OOO
Show compiler warnings
[
+
] Compiler args
[
-
]
Show input
Compilation time: 1.32 sec, absolute running time: 0.16 sec, cpu time: 0.01 sec, memory peak: 5 Mb, absolute service time: 1,54 sec
edit mode
|
history
|
discussion
4441