#include <algorithm>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include "speedrun.h"
// Akhmet Issa
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ent "\n"
const int maxn = 1e6 + 100;
const ll INF = (ll)2e18;
const int inf = (ll)2e9;
const int maxl = 20;
const int MOD = 1e9 + 7;
int S;
vector<int> g[maxn];
int used[maxn];
void assignHints(int subtask, int n, int A [], int B []){
int r = 1;
for(int i = 1; i < n; i++){
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
if(subtask == 2){
setHintLen(20);
for(int i = 1; i <= n; i++){
if(g[i].size() > 1) r = i;
}
for(int i = 1; i <= n; i++){
if(i == r) continue;
for(int j = 1; j <= 20; j++){
if(r & (1<<(j-1))) setHint(i, j, 1);
}
}
} else if(subtask == 1){
setHintLen(n);
for(int i = 1; i <= n; i++){
for(int to: g[i]){
setHint(i, to, 1);
}
}
} else if(subtask == 3){
setHintLen(20);
for(int i = 1; i <= n; i++){
int p = 1;
for(int to: g[i]){
for(int j = 0; j < 10; j++){
if(to & (1<<j)){
setHint(i, p++, 1);
}
}
}
}
}
}
void dfs(int subtask, int v, int pr, int n){
if(subtask == 2){
used[v] = 1;
int num = 0;
for(int i = 1; i <= 20; i++){
if(getHint(i)) num += (1<<(i-1));
}
if(!num){
for(int to = 1; to <= n; to++){
if(!used[to]){
goTo(to);
dfs(subtask, to, v, n);
}
}
} else{
if(!used[num]){
goTo(num);
dfs(subtask, num, v, n);
}
}
if(pr) goTo(pr);
} else if(subtask == 1){
used[v] = 1;
for(int to = 1; to <= n; to++){
if(getHint(to) && !used[to]){
goTo(to);
dfs(subtask, to, v, n);
}
}
if(pr) goTo(pr);
} else if(subtask == 3){
for(int i = 1; i <= 11; i += 10){
int to = 0;
for(int j = 0; j < 10; j++){
if(getHint(j + i)) to += (1<<j);
}
if(!used[to]){
goTo(to);
dfs(subtask, to, v, n);
}
}
if(pr) goTo(pr);
}
}
void speedrun(int subtask, int n, int start){
if(subtask == 2){
dfs(subtask, start, 0, n);
} else if(subtask == 1){
dfs(subtask, start, 0, n);
} else if(subtask == 3){
dfs(subtask, start, 0, n);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
47660 KB |
Output is correct |
2 |
Correct |
60 ms |
47716 KB |
Output is correct |
3 |
Correct |
57 ms |
47720 KB |
Output is correct |
4 |
Correct |
56 ms |
47680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
47624 KB |
Output is correct |
2 |
Correct |
54 ms |
47636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
90 ms |
47924 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
23856 KB |
setHintLen was never called |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
23820 KB |
setHintLen was never called |
2 |
Halted |
0 ms |
0 KB |
- |