Submission #467339

#TimeUsernameProblemLanguageResultExecution timeMemory
467339TlenekWodoruGame (eJOI20_game)C++14
20 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; int tab[100][100][5]; bool zaj[100][100]; int h=0; void DFS(int y, int x) { zaj[y][x]=1; if(tab[y][x][1]==0&&zaj[y-1][x]==0) { DFS(y-1,x); } if(tab[y][x][2]==0&&zaj[y][x+1]==0) { DFS(y,x+1); } if(tab[y][x][3]==0&&zaj[y+1][x]==0) { DFS(y+1,x); } if(tab[y][x][4]==0&&zaj[y][x-1]==0) { DFS(y,x-1); } h++; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m;cin>>n>>m; for(int i=0;i<=n+1;i++) { zaj[i][0]=1; zaj[i][m+1]=1; } for(int i=0;i<=n+1;i++) { zaj[0][i]=1; zaj[n+1][i]=1; } for(int i=1;i<=n+1;i++) { string A; cin>>A; for(int j=0;j<A.size();j++) { tab[i][j+1][1]=A[j]-48; tab[i-1][j+1][3]=A[j]-48; } } for(int i=1;i<=n;i++) { string A; cin>>A; for(int j=0;j<A.size();j++) { tab[i][j+1][4]=A[j]-48; tab[i][j][2]=A[j]-48; } } ///-=-==-==--==-=-==-==-==-==============-==-===--===--==-===-=== /**for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cout<<"{"<<tab[i][j][1]<<","<<tab[i][j][2]<<","<<tab[i][j][3]<<","<<tab[i][j][4]<<"} "; } cout<<endl; }**/ ///-=-=--==-==-==-=-==-==-==-=-==-==-==-=-==-==-==-==-==-==-=-==-==-=-==--==-=-=-= vector<int>U; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(zaj[i][j]==0&&(tab[i][j][1]==0||tab[i][j][2]==0||tab[i][j][3]==0)) { h=0; DFS(i,j); U.push_back(h); } } } sort(U.begin(),U.end()); int wynik=0; for(int i=0;i<U.size();i++) { if(i%2==0) { wynik-=U[i]; } else { wynik+=U[i]; } } cout<<wynik<<endl; return 0; }

Compilation message (stderr)

game.cpp: In function 'int main()':
game.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         for(int j=0;j<A.size();j++)
      |                     ~^~~~~~~~~
game.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int j=0;j<A.size();j++)
      |                     ~^~~~~~~~~
game.cpp:85:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |     for(int i=0;i<U.size();i++)
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...