Submission #152481

#TimeUsernameProblemLanguageResultExecution timeMemory
152481PedroBigManTetris (COCI17_tetris)C++14
80 / 80
3 ms380 KiB
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #define REP(i,a,b) for(ll i=a; i<b; i++) #define pb push_back #define mp make_pair #define pl pair<ll,ll> #define ff first #define ss second #define INF ((ll) pow(2,63) -1) ll insig; #define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);} void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;} ll N,M; vector<vector<char> > a; vector<vector<pl> > CC; vector<vector<bool> > visited; void DFS(ll x, ll y) { if(visited[x][y] || a[x][y]=='.') {return;} visited[x][y]=true; CC[CC.size()-1].pb(mp(x,y)); if(x>0 && a[x-1][y]==a[x][y]) {DFS(x-1,y);} if(x<N-1 && a[x+1][y]==a[x][y]) {DFS(x+1,y);} if(y>0 && a[x][y-1]==a[x][y]) {DFS(x,y-1);} if(y<M-1 && a[x][y+1]==a[x][y]) {DFS(x,y+1);} return; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>N>>M; vector<char> xx; vector<bool> xxx; REP(i,0,M) {xx.pb('a'); xxx.pb(false);} REP(i,0,N) {a.pb(xx); visited.pb(xxx);} REP(i,0,N) {REP(j,0,M) {cin>>a[i][j];}} vector<pl> use; REP(x,0,N) { REP(y,0,M) { if(!visited[x][y]) {CC.pb(use); DFS(x,y);} } } vector<ll> ans; REP(i,0,5) {ans.pb(0);} REP(i,0,CC.size()) { sort(CC[i].begin(),CC[i].end()); } pl c1,c2,c3,c4; ll xmi,xma,ymi,yma; REP(i,0,CC.size()) { if(CC[i].size()!=4) {continue;} c1=CC[i][0]; c2=CC[i][1]; c3=CC[i][2]; c4=CC[i][3]; xmi=c1.ff; xma=c4.ff; ymi=INF; yma=-1; REP(j,0,4) {ymi=min(ymi,CC[i][j].ss); yma=max(yma,CC[i][j].ss);} if(xma-xmi==1 && yma-ymi==1) {ans[0]++; continue;} if(max(xma-xmi,yma-ymi)==3) {ans[1]++; continue;} if(xma-xmi==2) { if(c1.ss==c4.ss) {ans[4]++;} else if(c1.ss<c4.ss) {ans[2]++;} else {ans[3]++;} } else { if(c1.ff==c3.ff || c2.ff==c4.ff) {ans[4]++;} else if(c1.ss>c3.ss) {ans[2]++;} else {ans[3]++;} } } REP(i,0,5) {cout<<ans[i]<<endl;} return 0; }

Compilation message (stderr)

tetris.cpp: In function 'void Out(std::vector<long long int>)':
tetris.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
tetris.cpp:19:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
tetris.cpp:19:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
tetris.cpp: In function 'int main()':
tetris.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
tetris.cpp:51:9:
     REP(i,0,CC.size())
         ~~~~~~~~~~~~~            
tetris.cpp:51:5: note: in expansion of macro 'REP'
     REP(i,0,CC.size())
     ^~~
tetris.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
tetris.cpp:56:9:
     REP(i,0,CC.size())
         ~~~~~~~~~~~~~            
tetris.cpp:56:5: note: in expansion of macro 'REP'
     REP(i,0,CC.size())
     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...