# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
923346 | 2024-02-07T06:47:28 Z | shoryu386 | Speedrun (RMI21_speedrun) | C++17 | 3500 ms | 4876 KB |
#include "speedrun.h" #include <bits/stdc++.h> using namespace std; bool vis[1007]; int parset[1007]; vector<int> adj[1007]; vector<int> dorder[1007]; int n; void dfs(int x, int p, int d){ vis[x] = 1; parset[x] = p; dorder[d].push_back(x); for (auto y : adj[x]){ if (!vis[y]){ dfs(y, x, d+1); } } } void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */ setHintLen(20); for (int x = 1; x < N; x++){ adj[A[x]].push_back(B[x]); adj[B[x]].push_back(A[x]); } //let root be 1 always dfs(1, 0, 0); vector<int> inorder; for (int x = 0; x <= N; x++){ for (auto y : dorder[x]){ inorder.push_back(y); } } //data 1 is par //data 2 is next int next[N+1]; for (int x = 0; x < N-1; x++){ next[ inorder[x] ] = inorder[x+1]; } next[inorder[N-1]] = inorder[0]; //encryption for (int x = 1; x <= N; x++){ for (int z = 0; z <= 9; z++){ if (parset[x] & (1<<z)){ setHint(x, z+1, 1); } } for (int z = 0; z <= 9; z++){ if (next[x] & (1<<z)){ setHint(x, z+11, 1); } } } return; } int par[1007]; int nextt[1007]; int cur; void setDetails(){ if (nextt[cur] != 0) return; par[cur] = 0; nextt[cur] = 0; for (int z = 0; z <= 9; z++){ if (getHint(z+1)){ par[cur] += (1<<z); } } for (int z = 0; z <= 9; z++){ if (getHint(z+11)){ nextt[cur] += (1<<z); } } } void assertGoTo(int x){ goTo(x); } void returnToRoot(){ setDetails(); if (cur == 1){ return; } assertGoTo(par[cur]); cur = par[cur]; returnToRoot(); } vector<int> moves[1007]; void trace(int x){ returnToRoot(); for (auto z : moves[x]){ assertGoTo(z); cur = z; } return; } void speedrun(int subtask, int N, int start) { /* your solution here */ cur = start; returnToRoot(); vector<int> inorder; inorder.push_back(1); int ptr = 0; int nodeCount = 1; while (nodeCount < N){ assert(ptr < inorder.size()); int nextnode = nextt[inorder.back()]; if (nextnode == 0) break; trace(inorder[ptr]); if (goTo(nextnode)){ nodeCount++; inorder.push_back(nextnode); cur = nextnode; moves[cur] = moves[inorder[ptr]]; moves[cur].push_back(cur); setDetails(); } else{ ptr++; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 181 ms | 2444 KB | Output is correct |
2 | Execution timed out | 3540 ms | 4876 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 1936 KB | Output is correct |
2 | Correct | 55 ms | 1652 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3532 ms | 3672 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 809 ms | 2140 KB | Output is correct |
2 | Correct | 243 ms | 2416 KB | Output is correct |
3 | Correct | 99 ms | 1688 KB | Output is correct |
4 | Correct | 3163 ms | 3412 KB | Output is correct |
5 | Correct | 542 ms | 1556 KB | Output is correct |
6 | Correct | 63 ms | 1708 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 482 ms | 2280 KB | Output is correct |
2 | Correct | 289 ms | 1900 KB | Output is correct |
3 | Correct | 117 ms | 1412 KB | Output is correct |
4 | Correct | 2960 ms | 3696 KB | Output is correct |
5 | Correct | 118 ms | 1664 KB | Output is correct |
6 | Correct | 600 ms | 2208 KB | Output is correct |
7 | Correct | 52 ms | 1420 KB | Output is correct |