# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64984 | 2018-08-06T11:11:44 Z | patrikpavic2 | Dango Maker (JOI18_dango_maker) | C++17 | 701 ms | 263168 KB |
#include <cstdio> #include <cstring> #include <vector> using namespace std; const int N = 3e3 + 50; const int M = N * N / 3; vector < int > v[M], k[N][N]; int ty[M], sl[M], bio[M], mat[M]; char s[N][N]; int n, m, edg, cnt = 1; int dfs( int node ) { if( bio[ node ] ) return 0; bio[ node ] = 1; for(int sus : v[node]){ if( mat[ sus ] == -1 || dfs( mat[ sus ]) ) { mat[ sus ] = node; return 1; } } return 0; } int matching( ) { int sol = 0; memset( mat, -1, sizeof( mat ) ); for( int i = 1; i < cnt; i++) { if(ty[i]) continue; sol += dfs(i); } return sol; } int main(){ memset(s, '.', sizeof(s)); scanf("%d%d", &n, &m); for(int i = 1;i<=n;i++){ for(int j = 1;j<=m;j++){ scanf(" %c", &s[i][j]); } } for(int i = 1;i<=n;i++){ for(int j = 1;j<=m;j++){ if(s[i][j] != 'G') continue; if(s[i - 1][j] == 'R' && s[i + 1][j] == 'W'){ k[i - 1][j].push_back(cnt); k[i + 1][j].push_back(cnt); k[i][j].push_back(cnt); cnt++; } if(s[i][j - 1] == 'R' && s[i][j + 1] == 'W'){ k[i][j - 1].push_back(cnt); k[i][j + 1].push_back(cnt); k[i][j].push_back(cnt); ty[cnt] = 1; cnt++; } } } for(int i = 1;i<=n;i++){ for(int j = 1;j<=m;j++){ if(k[i][j].size() == 2){ v[k[i][j][0]].push_back(k[i][j][1]); v[k[i][j][1]].push_back(k[i][j][0]); } } } printf("%d\n", cnt - matching() - 1); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 701 ms | 263168 KB | Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 701 ms | 263168 KB | Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 701 ms | 263168 KB | Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 | Halted | 0 ms | 0 KB | - |