제출 #981719

#제출 시각아이디문제언어결과실행 시간메모리
981719someoneIsland Hopping (JOI24_island)C++17
2 / 100
5 ms804 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], found[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) { if(found[i]) return; found[i] = true; int k = 1; while(k < n) { int nxt = query(i, k); add(i, nxt); if(nxt == pre[i]) 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...