이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000 + 10;
bool visited[maxn];
int st[maxn], Time = 0;
vector<int> g[maxn];
void dfs(int v){
visited[v] = 1;
st[v] = Time ++;
for (auto u : g[v])
if (!visited[u])
dfs(u);
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
for (int i = 0; i < M; i++){
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
for (int i = 0; i < N; i++)
sort(g[i].begin(), g[i].end());
dfs(0);
for (int i = 0; i < N; i++){
bool r = 0;
if (X & (1ll << (st[i] % 60)))
r = 1;
MessageBoard(i, r);
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000 + 10;
bool visited[maxn];
int st[maxn], Time = 0;
vector<int> g[maxn], t[maxn];
int now, board, cnt = 0;
int b[maxn];
void dfs(int v, int par = -1){
if (now == v)
b[st[v] % 60] = board;
for (auto u : t[v]){
if (u != par){
if (v == now and cnt < 120){
now = u;
cnt ++;
board = Move(u);
}
dfs(u, v);
}
}
if (now == v)
b[st[v] % 60] = board;
if (par != -1 and v == now and cnt < 120){
now = par;
cnt ++;
board = Move(par);
}
}
void DFS(int v){
visited[v] = 1;
st[v] = Time ++;
for (auto u : g[v]){
if (!visited[u]){
t[v].push_back(u);
t[u].push_back(v);
DFS(u);
}
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
for (int i = 0; i < M; i++){
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
for (int i = 0; i < N; i++)
sort(g[i].begin(), g[i].end());
memset(b, -1, sizeof b);
DFS(0);
now = P;
board = V;
dfs(P);
long long ret = 0;
for (int i = 0; i < 60; i++)
ret += 1ll * b[i] * (1ll << i);
return ret;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |