#include <bits/stdc++.h>
#include "Joi.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
static int N, M;
static vector<int> adj[10101];
static int C[10101], num;
static queue<int> Q;
static void dfs(int u){
if (C[u] != -1) return;
if (num >= 60) return;
C[u] = num++;
for (int v : adj[u]) dfs(v);
}
static LL Col(int u, LL chk){
if (C[u] == -1) return chk;
if (chk & (1ll<<C[u])) return chk;
chk |= (1ll<<C[u]);
if (__builtin_popcountl(chk) == 59) return chk;
for (int v : adj[u]) chk = Col(v, chk);
return chk;
}
void Joi(int n, int m, int A[], int B[], long long X, int T) {
N=n, M=m;
for (int i=0; i<M; i++) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
memset(C, -1, sizeof C);
dfs(0);
for (int i=0; i<N; i++){
if (C[i] == -1) continue;
for (int j : adj[i]) Q.push(j);
}
while (!Q.empty()){
int u = Q.front();
Q.pop();
if (C[u] != -1) continue;
LL chk = 0;
for (int v : adj[u]) chk = Col(v, chk);
for (int i=0; i<60; i++) if (~chk & (1ll<<i)) C[u] = i;
for (int v : adj[u]) Q.push(v);
}
for (int i=0; i<N; i++) MessageBoard(i, (X & (1ll << C[i])) ? 1 : 0);
}
#include <bits/stdc++.h>
#include "Ioi.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
static int N, M;
static vector<int> adj[10101];
static int C[10101], num;
static LL ans;
static queue<int> Q;
static void dfs(int u){
if (C[u] != -1) return;
if (num >= 60) return;
C[u] = num++;
for (int v : adj[u]) dfs(v);
}
static LL Col(int u, LL chk){
if (C[u] == -1) return chk;
if (chk & (1ll<<C[u])) return chk;
chk |= (1ll<<C[u]);
if (__builtin_popcountl(chk) == 59) return chk;
for (int v : adj[u]) chk = Col(v, chk);
return chk;
}
static LL Findans(int u, int p, LL chk){
if (chk & (1ll<<C[u])) return chk;
chk |= 1ll<<C[u];
ans |= (LL)Move(u)<<C[u];
for (int v : adj[u]) chk = Findans(v, u, chk);
Move(p);
return chk;
}
long long Ioi(int n, int m, int A[], int B[], int P, int V, int T) {
N=n, M=m;
for (int i=0; i<M; i++) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
memset(C, -1, sizeof C);
dfs(0);
for (int i=0; i<N; i++){
if (C[i] == -1) continue;
for (int j : adj[i]) Q.push(j);
}
while (!Q.empty()){
int u = Q.front();
Q.pop();
if (C[u] != -1) continue;
LL chk = 0;
for (int v : adj[u]) chk = Col(v, chk);
for (int i=0; i<60; i++) if (~chk & (1ll<<i)) C[u] = i;
for (int v : adj[u]) Q.push(v);
}
LL chk = 1ll<<C[P];
ans |= (LL)V<<C[P];
for (int v : adj[P]) {
chk = Findans(v, P, chk);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1400 KB |
Output is correct |
2 |
Correct |
4 ms |
1452 KB |
Output is correct |
3 |
Incorrect |
4 ms |
1408 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
76 ms |
3704 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1392 KB |
Output is correct |
2 |
Correct |
4 ms |
1392 KB |
Output is correct |
3 |
Correct |
4 ms |
1264 KB |
Output is correct |
4 |
Correct |
10 ms |
1556 KB |
Output is correct |
5 |
Correct |
9 ms |
1552 KB |
Output is correct |
6 |
Correct |
8 ms |
1688 KB |
Output is correct |
7 |
Correct |
9 ms |
1648 KB |
Output is correct |
8 |
Correct |
9 ms |
1688 KB |
Output is correct |
9 |
Correct |
31 ms |
2616 KB |
Output is correct |
10 |
Correct |
30 ms |
2752 KB |
Output is correct |
11 |
Correct |
30 ms |
2616 KB |
Output is correct |
12 |
Correct |
4 ms |
1496 KB |
Output is correct |
13 |
Correct |
4 ms |
1392 KB |
Output is correct |
14 |
Correct |
4 ms |
1392 KB |
Output is correct |
15 |
Correct |
4 ms |
1432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
81 ms |
3648 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
73 ms |
3668 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |