# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
217470 |
2020-03-29T20:02:27 Z |
Pajaraja |
Stray Cat (JOI20_stray) |
C++17 |
|
1109 ms |
18092 KB |
#include "Anthony.h"
#define MAXN 20007
#include <bits/stdc++.h>
namespace {
int a,b;
int d[MAXN],nz[6]={0,1,0,0,1,1};
std::vector<int> g[MAXN],ind[MAXN],X;
void dfs(int s,int f,int a)
{
int x=1-nz[a];
if(g[s].size() + (s==0) ==2) x=(a+1)%6;
for(int i=0;i<g[s].size();i++) if(g[s][i]!=f) {X[ind[s][i]]=nz[x]; dfs(g[s][i],s,x);}
}
}
std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V)
{
for(int i=0;i<M;i++) X.push_back(0);
a=A;
for(int i=0;i<M;i++) g[U[i]].push_back(V[i]);
for(int i=0;i<M;i++) ind[U[i]].push_back(i);
for(int i=0;i<M;i++) g[V[i]].push_back(U[i]);
for(int i=0;i<M;i++) ind[V[i]].push_back(i);
if(a>=3)
{
d[0]=0;
std::fill(d+1,d+N,-1);
std::queue<int> q;
q.push(0);
while(!q.empty())
{
int u=q.front();
q.pop();
for(int i=0;i<g[u].size();i++) if(d[g[u][i]]==-1)
{
d[g[u][i]]=d[u]+1;
q.push(g[u][i]);
}
for(int i=0;i<M;i++) X[i]=std::min(d[U[i]],d[V[i]])%3;
}
}
else dfs(0,0,0);
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
namespace {
int a, b,br,nz[6]={0,1,0,0,1,1},pr;
bool sig=false;
std::vector<int> vd;
}
void Init(int A, int B) {
a = A;
b = B;
}
int Move(std::vector<int> y) {
if(a>=3) {for(int i=0;i<3;i++) if(y[i]==0 && y[(i+1)%3]!=0) return (i+1)%3;}
else
{
br++;
int deg=y[0]+y[1]+(br!=1);
if(sig)
{
if(deg>=3)
{
pr=1-pr;
return pr;
}
if(y[0]!=0) pr=0;
else pr=1;
return pr;
}
if(deg==1)
{
sig=true;
if(br!=1) return -1;
if(y[0]!=0) pr=0;
else pr=1;
return pr;
}
if(deg>2)
{
if(br!=1) y[pr]++;
sig=true;
int t;
if(y[0]==1) t=0;
if(y[1]==1) t=1;
if(t==pr && br!=1) return -1;
else {pr=t; return pr;}
}
if(br<=3)
{
if(y[0]!=0) pr=0;
else pr=1;
if(br==1) vd.push_back(y[1]-pr);
vd.push_back(pr);
return pr;
}
if(br==4)
{
int op;
if(y[0]!=0) op=0;
else op=1;
vd.push_back(op);
bool ok=false;
for(int i=0;i<6;i++)
{
bool tok=true;
for(int j=0;j<5;j++) if(vd[j]!=nz[(i-j+6)%6]) tok=false;
if(tok) ok=true;
}
sig=true;
if(ok) {pr=op; return pr;}
else return -1;
}
}
}
Compilation message
Anthony.cpp: In function 'void {anonymous}::dfs(int, int, int)':
Anthony.cpp:13:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<g[s].size();i++) if(g[s][i]!=f) {X[ind[s][i]]=nz[x]; dfs(g[s][i],s,x);}
~^~~~~~~~~~~~
Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:35:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<g[u].size();i++) if(d[g[u][i]]==-1)
~^~~~~~~~~~~~
Anthony.cpp: At global scope:
Anthony.cpp:6:8: warning: '{anonymous}::b' defined but not used [-Wunused-variable]
int a,b;
^
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1055 ms |
17060 KB |
Output is correct |
2 |
Correct |
9 ms |
2560 KB |
Output is correct |
3 |
Correct |
1000 ms |
16528 KB |
Output is correct |
4 |
Correct |
1109 ms |
18092 KB |
Output is correct |
5 |
Correct |
1077 ms |
17836 KB |
Output is correct |
6 |
Correct |
1020 ms |
16528 KB |
Output is correct |
7 |
Correct |
1071 ms |
16792 KB |
Output is correct |
8 |
Correct |
1044 ms |
17360 KB |
Output is correct |
9 |
Correct |
1055 ms |
17516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1055 ms |
17060 KB |
Output is correct |
2 |
Correct |
9 ms |
2560 KB |
Output is correct |
3 |
Correct |
1000 ms |
16528 KB |
Output is correct |
4 |
Correct |
1109 ms |
18092 KB |
Output is correct |
5 |
Correct |
1077 ms |
17836 KB |
Output is correct |
6 |
Correct |
1020 ms |
16528 KB |
Output is correct |
7 |
Correct |
1071 ms |
16792 KB |
Output is correct |
8 |
Correct |
1044 ms |
17360 KB |
Output is correct |
9 |
Correct |
1055 ms |
17516 KB |
Output is correct |
10 |
Correct |
881 ms |
14680 KB |
Output is correct |
11 |
Correct |
866 ms |
14696 KB |
Output is correct |
12 |
Correct |
890 ms |
14648 KB |
Output is correct |
13 |
Correct |
907 ms |
14844 KB |
Output is correct |
14 |
Correct |
886 ms |
14824 KB |
Output is correct |
15 |
Correct |
871 ms |
15352 KB |
Output is correct |
16 |
Correct |
1063 ms |
17436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1041 ms |
14620 KB |
Output is correct |
2 |
Correct |
10 ms |
2560 KB |
Output is correct |
3 |
Correct |
977 ms |
14364 KB |
Output is correct |
4 |
Correct |
1069 ms |
15752 KB |
Output is correct |
5 |
Correct |
1062 ms |
15760 KB |
Output is correct |
6 |
Correct |
1061 ms |
14428 KB |
Output is correct |
7 |
Correct |
1020 ms |
14380 KB |
Output is correct |
8 |
Correct |
1051 ms |
15136 KB |
Output is correct |
9 |
Correct |
1050 ms |
15020 KB |
Output is correct |
10 |
Correct |
1065 ms |
14896 KB |
Output is correct |
11 |
Correct |
1064 ms |
15284 KB |
Output is correct |
12 |
Correct |
1020 ms |
14900 KB |
Output is correct |
13 |
Correct |
1025 ms |
14916 KB |
Output is correct |
14 |
Correct |
1048 ms |
15272 KB |
Output is correct |
15 |
Correct |
1041 ms |
15276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1041 ms |
14620 KB |
Output is correct |
2 |
Correct |
10 ms |
2560 KB |
Output is correct |
3 |
Correct |
977 ms |
14364 KB |
Output is correct |
4 |
Correct |
1069 ms |
15752 KB |
Output is correct |
5 |
Correct |
1062 ms |
15760 KB |
Output is correct |
6 |
Correct |
1061 ms |
14428 KB |
Output is correct |
7 |
Correct |
1020 ms |
14380 KB |
Output is correct |
8 |
Correct |
1051 ms |
15136 KB |
Output is correct |
9 |
Correct |
1050 ms |
15020 KB |
Output is correct |
10 |
Correct |
1065 ms |
14896 KB |
Output is correct |
11 |
Correct |
1064 ms |
15284 KB |
Output is correct |
12 |
Correct |
1020 ms |
14900 KB |
Output is correct |
13 |
Correct |
1025 ms |
14916 KB |
Output is correct |
14 |
Correct |
1048 ms |
15272 KB |
Output is correct |
15 |
Correct |
1041 ms |
15276 KB |
Output is correct |
16 |
Correct |
864 ms |
12812 KB |
Output is correct |
17 |
Correct |
861 ms |
12896 KB |
Output is correct |
18 |
Correct |
888 ms |
12836 KB |
Output is correct |
19 |
Correct |
884 ms |
12732 KB |
Output is correct |
20 |
Correct |
914 ms |
13176 KB |
Output is correct |
21 |
Correct |
903 ms |
13040 KB |
Output is correct |
22 |
Correct |
1079 ms |
15264 KB |
Output is correct |
23 |
Correct |
881 ms |
12844 KB |
Output is correct |
24 |
Correct |
874 ms |
12848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
2560 KB |
Output is correct |
2 |
Correct |
9 ms |
2560 KB |
Output is correct |
3 |
Correct |
10 ms |
2816 KB |
Output is correct |
4 |
Correct |
11 ms |
2816 KB |
Output is correct |
5 |
Correct |
10 ms |
2816 KB |
Output is correct |
6 |
Correct |
10 ms |
2816 KB |
Output is correct |
7 |
Correct |
12 ms |
2816 KB |
Output is correct |
8 |
Correct |
10 ms |
2816 KB |
Output is correct |
9 |
Correct |
10 ms |
2816 KB |
Output is correct |
10 |
Correct |
10 ms |
2816 KB |
Output is correct |
11 |
Correct |
11 ms |
2816 KB |
Output is correct |
12 |
Correct |
10 ms |
2560 KB |
Output is correct |
13 |
Correct |
10 ms |
2560 KB |
Output is correct |
14 |
Correct |
10 ms |
2560 KB |
Output is correct |
15 |
Correct |
11 ms |
2560 KB |
Output is correct |
16 |
Correct |
13 ms |
2560 KB |
Output is correct |
17 |
Correct |
11 ms |
2560 KB |
Output is correct |
18 |
Correct |
11 ms |
2560 KB |
Output is correct |
19 |
Correct |
10 ms |
2560 KB |
Output is correct |
20 |
Correct |
10 ms |
2560 KB |
Output is correct |
21 |
Correct |
10 ms |
2816 KB |
Output is correct |
22 |
Correct |
10 ms |
2560 KB |
Output is correct |
23 |
Correct |
11 ms |
2560 KB |
Output is correct |
24 |
Correct |
10 ms |
2816 KB |
Output is correct |
25 |
Correct |
10 ms |
2560 KB |
Output is correct |
26 |
Correct |
10 ms |
2560 KB |
Output is correct |
27 |
Correct |
10 ms |
2560 KB |
Output is correct |
28 |
Correct |
10 ms |
2560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
12440 KB |
Output is correct |
2 |
Correct |
60 ms |
14224 KB |
Output is correct |
3 |
Correct |
9 ms |
2560 KB |
Output is correct |
4 |
Correct |
44 ms |
12776 KB |
Output is correct |
5 |
Correct |
63 ms |
15616 KB |
Output is correct |
6 |
Correct |
62 ms |
15748 KB |
Output is correct |
7 |
Correct |
54 ms |
14820 KB |
Output is correct |
8 |
Correct |
54 ms |
14840 KB |
Output is correct |
9 |
Correct |
62 ms |
15740 KB |
Output is correct |
10 |
Correct |
67 ms |
15856 KB |
Output is correct |
11 |
Correct |
62 ms |
15608 KB |
Output is correct |
12 |
Correct |
62 ms |
15732 KB |
Output is correct |
13 |
Correct |
64 ms |
15604 KB |
Output is correct |
14 |
Correct |
67 ms |
15732 KB |
Output is correct |
15 |
Correct |
64 ms |
15616 KB |
Output is correct |
16 |
Correct |
66 ms |
15608 KB |
Output is correct |
17 |
Correct |
62 ms |
15344 KB |
Output is correct |
18 |
Correct |
67 ms |
15680 KB |
Output is correct |
19 |
Correct |
59 ms |
15352 KB |
Output is correct |
20 |
Correct |
59 ms |
15352 KB |
Output is correct |
21 |
Correct |
67 ms |
15360 KB |
Output is correct |
22 |
Correct |
60 ms |
15192 KB |
Output is correct |
23 |
Correct |
52 ms |
13128 KB |
Output is correct |
24 |
Correct |
52 ms |
13132 KB |
Output is correct |
25 |
Correct |
53 ms |
13472 KB |
Output is correct |
26 |
Correct |
57 ms |
13452 KB |
Output is correct |
27 |
Correct |
57 ms |
14300 KB |
Output is correct |
28 |
Correct |
57 ms |
14316 KB |
Output is correct |
29 |
Correct |
59 ms |
14300 KB |
Output is correct |
30 |
Correct |
64 ms |
14764 KB |
Output is correct |
31 |
Correct |
52 ms |
13132 KB |
Output is correct |
32 |
Correct |
52 ms |
13132 KB |
Output is correct |
33 |
Correct |
54 ms |
13400 KB |
Output is correct |
34 |
Correct |
58 ms |
13460 KB |
Output is correct |
35 |
Correct |
59 ms |
14244 KB |
Output is correct |
36 |
Correct |
57 ms |
14268 KB |
Output is correct |
37 |
Correct |
57 ms |
14104 KB |
Output is correct |
38 |
Correct |
59 ms |
14308 KB |
Output is correct |
39 |
Correct |
58 ms |
14264 KB |
Output is correct |
40 |
Correct |
60 ms |
14264 KB |
Output is correct |
41 |
Correct |
59 ms |
14912 KB |
Output is correct |
42 |
Correct |
56 ms |
14908 KB |
Output is correct |
43 |
Correct |
66 ms |
14732 KB |
Output is correct |
44 |
Correct |
61 ms |
15040 KB |
Output is correct |
45 |
Correct |
61 ms |
14912 KB |
Output is correct |
46 |
Correct |
65 ms |
15152 KB |
Output is correct |
47 |
Correct |
56 ms |
13952 KB |
Output is correct |
48 |
Correct |
56 ms |
13948 KB |
Output is correct |
49 |
Correct |
54 ms |
13816 KB |
Output is correct |
50 |
Correct |
56 ms |
14064 KB |
Output is correct |
51 |
Correct |
60 ms |
13164 KB |
Output is correct |
52 |
Correct |
59 ms |
13188 KB |
Output is correct |
53 |
Correct |
52 ms |
13020 KB |
Output is correct |
54 |
Correct |
53 ms |
13192 KB |
Output is correct |
55 |
Correct |
54 ms |
13188 KB |
Output is correct |
56 |
Correct |
53 ms |
13180 KB |
Output is correct |
57 |
Correct |
53 ms |
13196 KB |
Output is correct |
58 |
Correct |
52 ms |
13164 KB |
Output is correct |
59 |
Correct |
68 ms |
13420 KB |
Output is correct |
60 |
Correct |
53 ms |
13188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
12576 KB |
Output is correct |
2 |
Correct |
57 ms |
13824 KB |
Output is correct |
3 |
Correct |
9 ms |
2560 KB |
Output is correct |
4 |
Correct |
45 ms |
12784 KB |
Output is correct |
5 |
Correct |
63 ms |
15740 KB |
Output is correct |
6 |
Correct |
70 ms |
15820 KB |
Output is correct |
7 |
Correct |
53 ms |
14848 KB |
Output is correct |
8 |
Correct |
54 ms |
14840 KB |
Output is correct |
9 |
Correct |
65 ms |
15600 KB |
Output is correct |
10 |
Correct |
67 ms |
15700 KB |
Output is correct |
11 |
Correct |
66 ms |
15612 KB |
Output is correct |
12 |
Correct |
63 ms |
15604 KB |
Output is correct |
13 |
Correct |
66 ms |
15732 KB |
Output is correct |
14 |
Correct |
65 ms |
15876 KB |
Output is correct |
15 |
Correct |
65 ms |
15616 KB |
Output is correct |
16 |
Correct |
63 ms |
15728 KB |
Output is correct |
17 |
Correct |
61 ms |
15352 KB |
Output is correct |
18 |
Correct |
60 ms |
15316 KB |
Output is correct |
19 |
Correct |
59 ms |
15344 KB |
Output is correct |
20 |
Correct |
60 ms |
15352 KB |
Output is correct |
21 |
Correct |
60 ms |
15200 KB |
Output is correct |
22 |
Correct |
64 ms |
15572 KB |
Output is correct |
23 |
Correct |
51 ms |
13116 KB |
Output is correct |
24 |
Correct |
52 ms |
13116 KB |
Output is correct |
25 |
Correct |
54 ms |
13720 KB |
Output is correct |
26 |
Correct |
54 ms |
13452 KB |
Output is correct |
27 |
Correct |
58 ms |
14316 KB |
Output is correct |
28 |
Correct |
58 ms |
14428 KB |
Output is correct |
29 |
Correct |
62 ms |
14536 KB |
Output is correct |
30 |
Correct |
65 ms |
14292 KB |
Output is correct |
31 |
Correct |
52 ms |
13132 KB |
Output is correct |
32 |
Correct |
52 ms |
13128 KB |
Output is correct |
33 |
Correct |
54 ms |
13448 KB |
Output is correct |
34 |
Correct |
63 ms |
13396 KB |
Output is correct |
35 |
Correct |
58 ms |
14252 KB |
Output is correct |
36 |
Correct |
59 ms |
14176 KB |
Output is correct |
37 |
Correct |
60 ms |
14412 KB |
Output is correct |
38 |
Correct |
63 ms |
14100 KB |
Output is correct |
39 |
Correct |
57 ms |
14248 KB |
Output is correct |
40 |
Correct |
56 ms |
14036 KB |
Output is correct |
41 |
Correct |
64 ms |
15092 KB |
Output is correct |
42 |
Correct |
61 ms |
14796 KB |
Output is correct |
43 |
Correct |
60 ms |
14912 KB |
Output is correct |
44 |
Correct |
60 ms |
15028 KB |
Output is correct |
45 |
Correct |
62 ms |
15108 KB |
Output is correct |
46 |
Correct |
60 ms |
15048 KB |
Output is correct |
47 |
Correct |
56 ms |
13948 KB |
Output is correct |
48 |
Correct |
55 ms |
13912 KB |
Output is correct |
49 |
Correct |
58 ms |
13940 KB |
Output is correct |
50 |
Correct |
56 ms |
14060 KB |
Output is correct |
51 |
Correct |
54 ms |
13176 KB |
Output is correct |
52 |
Correct |
52 ms |
13172 KB |
Output is correct |
53 |
Correct |
53 ms |
13396 KB |
Output is correct |
54 |
Correct |
52 ms |
13192 KB |
Output is correct |
55 |
Correct |
52 ms |
13180 KB |
Output is correct |
56 |
Correct |
57 ms |
13184 KB |
Output is correct |
57 |
Correct |
53 ms |
13196 KB |
Output is correct |
58 |
Correct |
52 ms |
13188 KB |
Output is correct |
59 |
Correct |
53 ms |
13328 KB |
Output is correct |
60 |
Correct |
52 ms |
13188 KB |
Output is correct |