# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
889247 | 2023-12-19T08:53:07 Z | alexander707070 | Dango Maker (JOI18_dango_maker) | C++14 | 60 ms | 262144 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 60 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 60 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 60 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |