# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
733079 |
2023-04-30T04:36:47 Z |
cig32 |
None (JOI16_snowy) |
C++17 |
|
23 ms |
1796 KB |
#include "Anyalib.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
void Save(int place, int bit);
const int M = 10, MAXN = 500;
vector<int> v1[M];
vector<pair<int, int> > adj1[MAXN];
vector<int> stoa1, stob1;
int dep1[MAXN];
int ans1[MAXN];
int N_;
void InitAnya(int N, int *bruh1, int *bruh2) {
N_ = N;
for(int i=0; i<N-1; i++) {
stoa1.push_back(bruh1[i]);
stob1.push_back(bruh2[i]);
}
}
void dfs1(int node, int prv) {
dep1[node] = (prv == -1 ? 0 : dep1[prv] + 1);
if(prv != -1) v1[dep1[node] % M].push_back(node);
for(pair<int, int> x: adj1[node]) {
if(x.first != prv) {
ans1[x.first] = ans1[node] + x.second;
dfs1(x.first, node);
}
}
}
void Anya(int *bruh3) {
int N = N_;
for(int i=0; i<N; i++) {
adj1[i].clear();
}
for(int i=0; i<M; i++) {
v1[i].clear();
}
for(int i=0; i<N-1; i++) {
adj1[stoa1[i]].push_back({stob1[i], bruh3[i]});
adj1[stob1[i]].push_back({stoa1[i], bruh3[i]});
}
dfs1(0, -1);
int minsize = 1e9, id;
for(int i=0; i<M; i++) {
if(v1[i].size() < minsize) {
minsize = v1[i].size();
id = i;
}
}
for(int i=0; i<v1[id].size(); i++) {
for(int j=0; j<9; j++) {
int bruh = ans1[v1[id][i]] & (1 << j);
if(bruh > 0) bruh = 1;
Save(i * 9 + j, bruh);
}
}
for(int i=500; i<500+N-1; i++) {
Save(i, bruh3[i-500]);
}
}
#include "Borislib.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int Ask(int place);
const int M = 10, MAXN = 500;
vector<int> v2[M];
vector<int> adj2[MAXN];
vector<int> stoa2, stob2;
int dep2[MAXN];
int par2[MAXN];
map<pair<int,int>,int> idedge;
void dfs2(int node, int prv) {
dep2[node] = (prv == -1 ? 0 : dep2[prv] + 1);
if(prv != -1) v2[dep2[node] % M].push_back(node);
par2[node] = prv;
for(int x: adj2[node]) {
if(x != prv) {
dfs2(x, node);
}
}
}
int minsize, id;
void InitBoris(int N, int *bruh1, int *bruh2) {
for(int i=0; i<N; i++) {
adj2[i].clear();
}
for(int i=0; i<M; i++) {
v2[i].clear();
}
idedge.clear();
for(int i=0; i<N-1; i++) {
idedge[{bruh1[i], bruh2[i]}] = idedge[{bruh2[i], bruh1[i]}] = i;
adj2[bruh1[i]].push_back(bruh2[i]);
adj2[bruh2[i]].push_back(bruh1[i]);
stoa2.push_back(bruh1[i]);
stob2.push_back(bruh2[i]);
}
dfs2(0, -1);
minsize = 1e9;
for(int i=0; i<M; i++) {
if(v2[i].size() < minsize) {
minsize = v2[i].size();
id = i;
}
}
}
int Boris(int city) {
int ans = 0;
while(dep2[city] % M != id) {
if(city == 0) return ans;
ans += Ask(500 + idedge[{city, par2[city]}]);
city = par2[city];
}
for(int i=0; i<v2[id].size(); i++) {
if(v2[id][i] == city) {
int add = 0;
for(int j=i*9+8; j>=i*9; j--) {
add = add * 2 + Ask(j);
}
ans += add;
}
}
return ans;
}
Compilation message
Anya.cpp: In function 'void Anya(int*)':
Anya.cpp:56:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
56 | if(v1[i].size() < minsize) {
| ~~~~~~~~~~~~~^~~~~~~~~
Anya.cpp:61:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(int i=0; i<v1[id].size(); i++) {
| ~^~~~~~~~~~~~~~
Boris.cpp: In function 'void InitBoris(int, int*, int*)':
Boris.cpp:51:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
51 | if(v2[i].size() < minsize) {
| ~~~~~~~~~~~~~^~~~~~~~~
Boris.cpp: In function 'int Boris(int)':
Boris.cpp:65:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(int i=0; i<v2[id].size(); i++) {
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
656 KB |
Output is correct |
2 |
Correct |
1 ms |
648 KB |
Output is correct |
3 |
Correct |
3 ms |
704 KB |
Output is correct |
4 |
Correct |
3 ms |
872 KB |
Output is correct |
5 |
Correct |
5 ms |
928 KB |
Output is correct |
6 |
Correct |
6 ms |
928 KB |
Output is correct |
7 |
Correct |
7 ms |
928 KB |
Output is correct |
8 |
Correct |
5 ms |
940 KB |
Output is correct |
9 |
Correct |
7 ms |
928 KB |
Output is correct |
10 |
Correct |
6 ms |
936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1204 KB |
Output is correct |
2 |
Correct |
8 ms |
1232 KB |
Output is correct |
3 |
Correct |
8 ms |
1204 KB |
Output is correct |
4 |
Correct |
8 ms |
1228 KB |
Output is correct |
5 |
Correct |
8 ms |
1228 KB |
Output is correct |
6 |
Correct |
9 ms |
1240 KB |
Output is correct |
7 |
Correct |
7 ms |
1240 KB |
Output is correct |
8 |
Correct |
8 ms |
1176 KB |
Output is correct |
9 |
Correct |
8 ms |
1212 KB |
Output is correct |
10 |
Correct |
8 ms |
1240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1712 KB |
Output is correct |
2 |
Correct |
20 ms |
1560 KB |
Output is correct |
3 |
Correct |
20 ms |
1656 KB |
Output is correct |
4 |
Correct |
19 ms |
1648 KB |
Output is correct |
5 |
Correct |
20 ms |
1740 KB |
Output is correct |
6 |
Correct |
19 ms |
1776 KB |
Output is correct |
7 |
Correct |
18 ms |
1672 KB |
Output is correct |
8 |
Correct |
20 ms |
1656 KB |
Output is correct |
9 |
Correct |
19 ms |
1688 KB |
Output is correct |
10 |
Correct |
19 ms |
1692 KB |
Output is correct |
11 |
Correct |
19 ms |
1744 KB |
Output is correct |
12 |
Correct |
19 ms |
1696 KB |
Output is correct |
13 |
Correct |
20 ms |
1684 KB |
Output is correct |
14 |
Correct |
20 ms |
1704 KB |
Output is correct |
15 |
Correct |
19 ms |
1680 KB |
Output is correct |
16 |
Correct |
20 ms |
1708 KB |
Output is correct |
17 |
Correct |
20 ms |
1696 KB |
Output is correct |
18 |
Correct |
20 ms |
1684 KB |
Output is correct |
19 |
Correct |
19 ms |
1692 KB |
Output is correct |
20 |
Correct |
19 ms |
1696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1704 KB |
Output is correct |
2 |
Correct |
20 ms |
1596 KB |
Output is correct |
3 |
Correct |
19 ms |
1628 KB |
Output is correct |
4 |
Correct |
20 ms |
1688 KB |
Output is correct |
5 |
Correct |
20 ms |
1668 KB |
Output is correct |
6 |
Correct |
19 ms |
1644 KB |
Output is correct |
7 |
Correct |
20 ms |
1628 KB |
Output is correct |
8 |
Correct |
19 ms |
1656 KB |
Output is correct |
9 |
Correct |
20 ms |
1708 KB |
Output is correct |
10 |
Correct |
20 ms |
1644 KB |
Output is correct |
11 |
Correct |
22 ms |
1652 KB |
Output is correct |
12 |
Correct |
19 ms |
1692 KB |
Output is correct |
13 |
Correct |
20 ms |
1712 KB |
Output is correct |
14 |
Correct |
20 ms |
1700 KB |
Output is correct |
15 |
Correct |
20 ms |
1652 KB |
Output is correct |
16 |
Correct |
18 ms |
1772 KB |
Output is correct |
17 |
Correct |
20 ms |
1692 KB |
Output is correct |
18 |
Correct |
20 ms |
1688 KB |
Output is correct |
19 |
Correct |
20 ms |
1664 KB |
Output is correct |
20 |
Correct |
20 ms |
1688 KB |
Output is correct |
21 |
Correct |
19 ms |
1696 KB |
Output is correct |
22 |
Correct |
22 ms |
1672 KB |
Output is correct |
23 |
Correct |
20 ms |
1676 KB |
Output is correct |
24 |
Correct |
20 ms |
1712 KB |
Output is correct |
25 |
Correct |
20 ms |
1688 KB |
Output is correct |
26 |
Correct |
20 ms |
1648 KB |
Output is correct |
27 |
Correct |
20 ms |
1700 KB |
Output is correct |
28 |
Correct |
19 ms |
1680 KB |
Output is correct |
29 |
Correct |
20 ms |
1648 KB |
Output is correct |
30 |
Correct |
20 ms |
1720 KB |
Output is correct |
31 |
Correct |
20 ms |
1656 KB |
Output is correct |
32 |
Correct |
19 ms |
1796 KB |
Output is correct |
33 |
Correct |
19 ms |
1676 KB |
Output is correct |
34 |
Correct |
20 ms |
1688 KB |
Output is correct |
35 |
Correct |
20 ms |
1684 KB |
Output is correct |
36 |
Correct |
20 ms |
1680 KB |
Output is correct |
37 |
Correct |
21 ms |
1704 KB |
Output is correct |
38 |
Correct |
20 ms |
1712 KB |
Output is correct |
39 |
Correct |
20 ms |
1700 KB |
Output is correct |
40 |
Correct |
20 ms |
1636 KB |
Output is correct |
41 |
Correct |
21 ms |
1580 KB |
Output is correct |
42 |
Correct |
20 ms |
1648 KB |
Output is correct |
43 |
Correct |
19 ms |
1680 KB |
Output is correct |
44 |
Correct |
23 ms |
1672 KB |
Output is correct |
45 |
Correct |
20 ms |
1628 KB |
Output is correct |
46 |
Correct |
20 ms |
1680 KB |
Output is correct |
47 |
Correct |
20 ms |
1688 KB |
Output is correct |
48 |
Correct |
19 ms |
1644 KB |
Output is correct |
49 |
Correct |
19 ms |
1692 KB |
Output is correct |
50 |
Correct |
19 ms |
1620 KB |
Output is correct |