Submission #981712

#TimeUsernameProblemLanguageResultExecution timeMemory
981712someoneIsland Hopping (JOI24_island)C++17
2 / 100
5 ms600 KiB
#include "island.h" #include <algorithm> #include <iostream> using namespace std; const int M = 342; int pre[M], n, l; bool adj[M][M], reported[M][M]; void add(int x, int y) { adj[x][y] = adj[y][x] = true; pre[x] = max(pre[x], y); pre[y] = max(pre[y], x); if(!reported[x][y]) { answer(x, y); reported[x][y] = reported[y][x] = true; } } void find(int i) { int k = 1; while(k < n) { int nxt = query(i, k); if(nxt != pre[i]) { add(i, nxt); } else { k = n; } k++; } } void solve(int nb, int l) { n = nb; for(int i = 1; i <= n; i++) pre[i] = -1; for(int i = n; i > 0; i--) { if(pre[i] == -1) { int k = 1; while(k < n) { int nxt = query(i, k); bool ok = true; for(int j = 1; j <= n; j++) if(adj[i][j] && adj[j][nxt]) ok = false; if(ok) { add(i, nxt); find(nxt); } else { k = n; } k++; } } else { find(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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...