Submission #889247

#TimeUsernameProblemLanguageResultExecution timeMemory
889247alexander707070Dango Maker (JOI18_dango_maker)C++14
0 / 100
60 ms262144 KiB
#include<bits/stdc++.h> #define MAXN 20000007 using namespace std; int n,m; char t[3007][3007]; vector<int> v[MAXN]; int li[MAXN]; bool dfs(int x,int p){ li[x]=1; for(int i=0;i<v[x].size();i++){ if(v[x][i]==p)continue; if(li[v[x][i]]==0 and dfs(v[x][i],x))return true; if(li[v[x][i]]==1)return true; } li[x]=2; return false; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i=1;i<=n;i++){ for(int f=1;f<=m;f++){ cin>>t[i][f]; } } for(int i=1;i<=n-2;i++){ for(int f=1;f<=m-2;f++){ if(t[i][f]=='R' and t[i][f+1]=='G' and t[i][f+2]=='W' and t[i+1][f]=='G' and t[i+2][f]=='W'){ v[i*m+f].push_back(i*m+f+n*m); v[i*m+f+n*m].push_back(i*m+f); } } } for(int i=2;i<=n-1;i++){ for(int f=2;f<=m-1;f++){ if(t[i][f]=='G' and t[i][f-1]=='R' and t[i][f+1]=='W' and t[i-1][f]=='R' and t[i+1][f]=='W'){ v[i*m+f-1].push_back((i-1)*m+f+n*m); v[(i-1)*m+f+n*m].push_back(i*m+f-1); } } } for(int i=3;i<=n;i++){ for(int f=3;f<=m;f++){ if(t[i][f]=='W' and t[i][f-2]=='R' and t[i][f-1]=='G' and t[i-2][f]=='R' and t[i-1][f]=='G'){ v[i*m+f-2].push_back((i-2)*m+f+n*m); v[(i-2)*m+f+n*m].push_back(i*m+f-2); } } } for(int i=1;i<=3*n*m;i++){ if(li[i]==0){ if(dfs(i,0))cout<<1/0; } } cout<<"OK\n"; return 0; }

Compilation message (stderr)

dango_maker.cpp: In function 'bool dfs(int, int)':
dango_maker.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0;i<v[x].size();i++){
      |                 ~^~~~~~~~~~~~
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:67:32: warning: division by zero [-Wdiv-by-zero]
   67 |             if(dfs(i,0))cout<<1/0;
      |                               ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...