# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
257499 |
2020-08-04T11:00:32 Z |
songc |
None (JOI16_snowy) |
C++14 |
|
39 ms |
4336 KB |
#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
static int N, D[550], S[550], P[550];
static int A[550], B[550], C[550][550];
static vector<int> adj[550], V;
static void dfs(int u, int p, int c){
D[u] = 1, P[u] = c;
for (int v : adj[u]){
if (v == p) continue;
dfs(v, u, c+C[u][v]);
D[u] += D[v];
}
if (D[u] >= 11 || u==0) D[u]=0, V.push_back(u);
}
void InitAnya(int n, int a[], int b[]) {
N=n;
for (int i=0; i<N; i++) adj[i].clear();
for (int i=0; i<N-1; i++){
A[i] = a[i], B[i] = b[i];
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
}
void Anya(int c[]) {
memset(C, 0, sizeof C);
for (int i=0; i<N-1; i++) C[A[i]][B[i]] = C[B[i]][A[i]] = c[i], Save(i, c[i]);
V.clear();
dfs(0, -1, 0);
for (int i=0; i<V.size(); i++) for (int j=0; j<9; j++) Save(N-1+i*9+j, !!(P[V[i]]&(1<<j)));
}
#include "Borislib.h"
#include <bits/stdc++.h>
using namespace std;
static int N, D[550], S[550], P[550], X[550], num;
static int A[550], B[550], C[550][550];
static vector<int> adj[550];
static void dfs(int u, int p){
D[u] = 1, P[u] = p;
for (int v : adj[u]){
if (v == p) continue;
dfs(v, u);
D[u] += D[v];
}
if (D[u] >= 10 || u==0) D[u]=0, X[u]=++num;
}
void InitBoris(int n, int a[], int b[]) {
N=n, num=0;
memset(S, 0, sizeof S);
memset(X, 0, sizeof X);
for (int i=0; i<N; i++) adj[i].clear();
for (int i=0; i<N-1; i++){
A[i] = a[i], B[i] = b[i];
C[A[i]][B[i]] = C[B[i]][A[i]] = i;
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
dfs(0, -1);
}
int Boris(int u){
int ans=0;
while (!X[u]){
ans += Ask(C[u][P[u]]);
u = P[u];
}
for (int i=0; i<9; i++) if (Ask(N-1+(X[u]-1)*9+i)) ans += (1<<i);
return ans;
}
Compilation message
Anya.cpp: In function 'void Anya(int*)':
Anya.cpp:34:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<V.size(); i++) for (int j=0; j<9; j++) Save(N-1+i*9+j, !!(P[V[i]]&(1<<j)));
~^~~~~~~~~
Anya.cpp: At global scope:
Anya.cpp:5:23: warning: 'S' defined but not used [-Wunused-variable]
static int N, D[550], S[550], P[550];
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3072 KB |
Output is correct |
2 |
Correct |
4 ms |
3072 KB |
Output is correct |
3 |
Correct |
9 ms |
3328 KB |
Output is correct |
4 |
Incorrect |
15 ms |
3328 KB |
Wrong Answer [7] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
3584 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
4080 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
4336 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |