Submission #982709

#TimeUsernameProblemLanguageResultExecution timeMemory
982709vjudge1Mars (APIO22_mars)C++17
14 / 100
9 ms4276 KiB
#include "mars.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define deb(x) cout<<#x<<": "<<x<<endl; string process(vector <vector<string>> a, int i, int j, int k, int n) { // deb(i); // deb(j); // deb(k); string ans=""; if(n==1){ int cont=1; queue<pair<int,pair<int,int>>> q; vector<vector<int>> grid (a.size(), vector<int> (a.size(), 0)); for(int i=0; i<a.size(); ++i){ for(int j=0;j<a.size(); ++j){ grid[i][j]=a[i][j][0]-'0'; } } for(int i=0; i<a.size(); ++i){ for(int j=0; j<a.size(); ++j){ if(grid[i][j]==1){ cont++; q.push({cont,{i,j}}); while(!q.empty()){ int a=q.front().first; int b=q.front().second.first; int c=q.front().second.second; q.pop(); if(grid[b][c]!=1) continue; grid[b][c]=a; if(b-1>=0){ if(grid[b-1][c]==1){ q.push({a, {b-1,c}}); } } if(c+1<grid.size()){ if(grid[b][c+1]==1){ q.push({a, {b,c+1}}); } } if(b+1<grid.size()){ if(grid[b+1][c]==1){ q.push({a, {b+1,c}}); } } if(c-1>=0){ if(grid[b][c-1]==1){ q.push({a, {b, c-1}}); } } } } } } cont--; for(int i=0; i<100; ++i){ if(cont%2==0){ ans+='0'; } else{ ans+='1'; } cont/=2; } return ans; } if(k!=n-1){ for(int i=0; i<=2; ++i){ if(i!=2){ for(int j=0; j<=2; ++j){ if(j!=2){ ans+=a[i][j][0]; } else{ for(int x=0; x<2*k+1; ++x){ ans+=a[i][j][x]; } } } } else{ for(int j=0; j<2*k+1; ++j){ for(int x=0; x<=2; ++x){ if(x!=2){ ans+=a[i][x][(2*k+1)*j]; } else{ for(int l=0; l<2*k+1; ++l){ ans+=a[i][x][(2*k+1)*j+l]; } } } } } } while(ans.size()<100){ ans+='0'; } return ans; } vector<vector<int>> grid (2*n+1, vector<int> (2*n+1, 0)); for(int i=0; i<=2; ++i){ if(i!=2){ for(int j=0; j<=2; ++j){ if(j!=2){ grid[i][j]=a[i][j][0]-'0'; } else{ for(int x=0; x<2*k+1; ++x){ grid[i][x+2]=a[i][j][x]-'0'; } } } } else{ for(int j=0; j<2*k+1; ++j){ for(int x=0; x<=2; ++x){ if(x!=2){ grid[i+j][x]=a[i][x][(2*k+1)*j]-'0'; } else{ for(int l=0; l<2*k+1; ++l){ grid[i+j][x+l]=a[i][x][(2*k+1)*j+l]-'0'; } } } } } } // deb("hlp"); int cont=1; queue<pair<int,pair<int,int>>>q; for(int i=0; i<grid.size(); ++i){ for(int j=0; j<grid.size(); ++j){ // deb(i); // deb(j); // deb(grid[i][j]); if(grid[i][j]==1){ cont++; q.push({cont,{i,j}}); while(!q.empty()){ int a=q.front().first; int b=q.front().second.first; int c=q.front().second.second; q.pop(); // deb(a); // deb(b); // deb(c); if(grid[b][c]!=1) continue; grid[b][c]=a; if(b-1>=0){ if(grid[b-1][c]==1){ q.push({a, {b-1,c}}); } } if(c+1<grid.size()){ if(grid[b][c+1]==1){ q.push({a, {b,c+1}}); } } if(b+1<grid.size()){ if(grid[b+1][c]==1){ q.push({a, {b+1,c}}); } } if(c-1>=0){ if(grid[b][c-1]==1){ q.push({a, {b, c-1}}); } } } } } } // deb("hlp2"); cont--; for(int i=0; i<100; ++i){ if(cont%2==0){ ans+='0'; } else{ ans+='1'; } cont/=2; } return ans; }

Compilation message (stderr)

mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:16:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   for(int i=0; i<a.size(); ++i){
      |                ~^~~~~~~~~
mars.cpp:17:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |    for(int j=0;j<a.size(); ++j){
      |                ~^~~~~~~~~
mars.cpp:21:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(int i=0; i<a.size(); ++i){
      |                ~^~~~~~~~~
mars.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    for(int j=0; j<a.size(); ++j){
      |                 ~^~~~~~~~~
mars.cpp:38:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |       if(c+1<grid.size()){
      |          ~~~^~~~~~~~~~~~
mars.cpp:43:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |       if(b+1<grid.size()){
      |          ~~~^~~~~~~~~~~~
mars.cpp:138:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  138 |   for(int i=0; i<grid.size(); ++i){
      |                ~^~~~~~~~~~~~
mars.cpp:139:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  139 |    for(int j=0; j<grid.size(); ++j){
      |                 ~^~~~~~~~~~~~
mars.cpp:161:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  161 |       if(c+1<grid.size()){
      |          ~~~^~~~~~~~~~~~
mars.cpp:166:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  166 |       if(b+1<grid.size()){
      |          ~~~^~~~~~~~~~~~
#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...
#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...