# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1012420 |
2024-07-02T06:36:22 Z |
pcc |
None (JOI16_snowy) |
C++17 |
|
15 ms |
2044 KB |
#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fs first
#define sc second
namespace ANYA{
const int mxn = 505;
const int W = 9;
vector<pii> tree[mxn];
int par[mxn];
int head[mxn];
int ptr;
int N;
bitset<mxn> isp;
int dep[mxn];
int cnt[W];
vector<pii> edges;
void dfs(int now){
cnt[dep[now]%W]++;
for(auto [nxt,w]:tree[now]){
if(nxt == par[now])continue;
dep[nxt] = dep[now]+w;
par[nxt] = now;
dfs(nxt);
}
return;
}
void InitAnya(int NN , int A[] , int B[]) {
cerr<<"INIT ANYA IN!"<<endl;
N = NN;
for(int i = 0;i+1<N;i++){
int a = A[i],b = B[i];
tree[a].push_back(pii(b,1));
tree[b].push_back(pii(a,1));
edges.push_back(pii(a,b));
}
dfs(0);
auto d = min_element(cnt,cnt+W)-cnt;
for(int i = 0;i<N;i++){
if(dep[i]%W == d){
isp[i] = true;
head[i] = ptr;
ptr += W;
}
else{
head[i] = ptr++;
}
}
for(auto &[a,b]:edges){
if(dep[a]>dep[b])swap(a,b);
}
cerr<<"INIT ANYA OUT!"<<endl;
return;
}
void writeint(int h,int num,int wid){
for(int i = 0;i<wid;i++){
if(num&(1<<i))Save(h+i,1);
else Save(h+i,0);
}
return;
}
void Anya(int C[]) {
for(auto &i:tree)i.clear();
for(int i = 0;i<edges.size();i++){
auto &[a,b] = edges[i];
tree[a].push_back(pii(b,C[i]));
}
dfs(0);
for(int i = 0;i<edges.size();i++){
auto &[a,b] = edges[i];
if(isp[b])writeint(head[b],dep[b],W);
else writeint(head[b],C[i],1);
}
}
}
void InitAnya(int NN , int A[] , int B[]) {
ANYA::InitAnya(NN,A,B);
return;
}
void Anya(int C[]){
ANYA::Anya(C);
return;
}
#include "Borislib.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fs first
#define sc second
namespace BORIS{
const int mxn = 505;
const int W = 9;
bitset<mxn> isp;
int dep[mxn],cnt[W],par[mxn],head[mxn];
vector<pii> tree[mxn];
int ptr = 0;
int N;
void dfs(int now){
cnt[dep[now]%W]++;
for(auto [nxt,w]:tree[now]){
if(nxt == par[now])continue;
par[nxt] = now;
dep[nxt] = dep[now]+1;
dfs(nxt);
}
return;
}
void InitBoris(int NN , int A[] , int B[]) {
N = NN;
for(int i = 0;i+1<N;i++){
int a = A[i],b = B[i];
tree[a].push_back(pii(b,1));
tree[b].push_back(pii(a,1));
}
dfs(0);
int d = min_element(cnt,cnt+W)-cnt;
for(int i = 0;i<N;i++){
if(dep[i]%W == d){
isp[i] = true;
head[i] = ptr;
ptr += W;
}
else{
head[i] = ptr++;
}
}
return;
}
int readint(int h,int wid){
int re = 0;
for(int i = 0;i<wid;i++){
if(Ask(h+i))re |= 1<<i;
}
return re;
}
int Boris(int city) {
int now = city;
int ans = 0;
while(now&&!isp[now]){
ans += readint(head[now],1);
now = par[now];
}
if(now)ans += readint(head[now],W);
return ans;
}
}
void InitBoris(int N , int A[] , int B[]) {
BORIS::InitBoris(N,A,B);
}
int Boris(int city){
return BORIS::Boris(city);
}
Compilation message
Anya.cpp: In function 'void ANYA::Anya(int*)':
Anya.cpp:72:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for(int i = 0;i<edges.size();i++){
| ~^~~~~~~~~~~~~
Anya.cpp:77:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
77 | for(int i = 0;i<edges.size();i++){
| ~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
904 KB |
Output is correct |
2 |
Correct |
2 ms |
800 KB |
Output is correct |
3 |
Correct |
2 ms |
848 KB |
Output is correct |
4 |
Correct |
3 ms |
1132 KB |
Output is correct |
5 |
Correct |
3 ms |
1136 KB |
Output is correct |
6 |
Correct |
7 ms |
1180 KB |
Output is correct |
7 |
Correct |
4 ms |
1204 KB |
Output is correct |
8 |
Correct |
3 ms |
1236 KB |
Output is correct |
9 |
Correct |
4 ms |
1204 KB |
Output is correct |
10 |
Correct |
3 ms |
1064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1244 KB |
Output is correct |
2 |
Correct |
4 ms |
1248 KB |
Output is correct |
3 |
Correct |
5 ms |
1252 KB |
Output is correct |
4 |
Correct |
5 ms |
1248 KB |
Output is correct |
5 |
Correct |
5 ms |
1248 KB |
Output is correct |
6 |
Correct |
8 ms |
1240 KB |
Output is correct |
7 |
Correct |
5 ms |
1244 KB |
Output is correct |
8 |
Correct |
8 ms |
1248 KB |
Output is correct |
9 |
Correct |
8 ms |
1252 KB |
Output is correct |
10 |
Correct |
4 ms |
1248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1732 KB |
Output is correct |
2 |
Correct |
11 ms |
1736 KB |
Output is correct |
3 |
Correct |
11 ms |
1728 KB |
Output is correct |
4 |
Correct |
13 ms |
1736 KB |
Output is correct |
5 |
Correct |
12 ms |
1724 KB |
Output is correct |
6 |
Correct |
12 ms |
1696 KB |
Output is correct |
7 |
Correct |
13 ms |
1724 KB |
Output is correct |
8 |
Correct |
13 ms |
1720 KB |
Output is correct |
9 |
Correct |
11 ms |
1744 KB |
Output is correct |
10 |
Correct |
12 ms |
1764 KB |
Output is correct |
11 |
Correct |
13 ms |
1728 KB |
Output is correct |
12 |
Correct |
13 ms |
1724 KB |
Output is correct |
13 |
Correct |
14 ms |
1728 KB |
Output is correct |
14 |
Correct |
11 ms |
1728 KB |
Output is correct |
15 |
Correct |
12 ms |
1728 KB |
Output is correct |
16 |
Correct |
13 ms |
1688 KB |
Output is correct |
17 |
Correct |
12 ms |
1732 KB |
Output is correct |
18 |
Correct |
12 ms |
1728 KB |
Output is correct |
19 |
Correct |
11 ms |
1728 KB |
Output is correct |
20 |
Correct |
15 ms |
1732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1684 KB |
Output is correct |
2 |
Correct |
13 ms |
1748 KB |
Output is correct |
3 |
Correct |
12 ms |
1716 KB |
Output is correct |
4 |
Correct |
13 ms |
1728 KB |
Output is correct |
5 |
Correct |
14 ms |
1820 KB |
Output is correct |
6 |
Correct |
12 ms |
1732 KB |
Output is correct |
7 |
Correct |
14 ms |
1808 KB |
Output is correct |
8 |
Correct |
11 ms |
1728 KB |
Output is correct |
9 |
Correct |
14 ms |
1728 KB |
Output is correct |
10 |
Correct |
12 ms |
1688 KB |
Output is correct |
11 |
Correct |
13 ms |
1708 KB |
Output is correct |
12 |
Correct |
11 ms |
1728 KB |
Output is correct |
13 |
Correct |
13 ms |
1728 KB |
Output is correct |
14 |
Correct |
13 ms |
1728 KB |
Output is correct |
15 |
Correct |
11 ms |
1724 KB |
Output is correct |
16 |
Correct |
9 ms |
1696 KB |
Output is correct |
17 |
Correct |
12 ms |
1736 KB |
Output is correct |
18 |
Correct |
13 ms |
1708 KB |
Output is correct |
19 |
Correct |
13 ms |
1696 KB |
Output is correct |
20 |
Correct |
13 ms |
1732 KB |
Output is correct |
21 |
Correct |
13 ms |
1728 KB |
Output is correct |
22 |
Correct |
14 ms |
1724 KB |
Output is correct |
23 |
Correct |
13 ms |
1668 KB |
Output is correct |
24 |
Correct |
13 ms |
1720 KB |
Output is correct |
25 |
Correct |
13 ms |
1960 KB |
Output is correct |
26 |
Correct |
12 ms |
1724 KB |
Output is correct |
27 |
Correct |
13 ms |
1724 KB |
Output is correct |
28 |
Correct |
13 ms |
1724 KB |
Output is correct |
29 |
Correct |
13 ms |
1724 KB |
Output is correct |
30 |
Correct |
15 ms |
2044 KB |
Output is correct |
31 |
Correct |
12 ms |
1724 KB |
Output is correct |
32 |
Correct |
11 ms |
1728 KB |
Output is correct |
33 |
Correct |
11 ms |
1728 KB |
Output is correct |
34 |
Correct |
9 ms |
1728 KB |
Output is correct |
35 |
Correct |
9 ms |
1728 KB |
Output is correct |
36 |
Correct |
11 ms |
1728 KB |
Output is correct |
37 |
Correct |
11 ms |
1652 KB |
Output is correct |
38 |
Correct |
12 ms |
1736 KB |
Output is correct |
39 |
Correct |
12 ms |
1656 KB |
Output is correct |
40 |
Correct |
12 ms |
1720 KB |
Output is correct |
41 |
Correct |
11 ms |
1724 KB |
Output is correct |
42 |
Correct |
9 ms |
1720 KB |
Output is correct |
43 |
Correct |
9 ms |
1720 KB |
Output is correct |
44 |
Correct |
12 ms |
1728 KB |
Output is correct |
45 |
Correct |
12 ms |
1740 KB |
Output is correct |
46 |
Correct |
11 ms |
1716 KB |
Output is correct |
47 |
Correct |
12 ms |
1728 KB |
Output is correct |
48 |
Correct |
13 ms |
1716 KB |
Output is correct |
49 |
Correct |
12 ms |
1728 KB |
Output is correct |
50 |
Correct |
12 ms |
1716 KB |
Output is correct |