# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
234826 |
2020-05-25T19:07:48 Z |
medk |
Stray Cat (JOI20_stray) |
C++14 |
|
72 ms |
16892 KB |
#include <bits/stdc++.h>
#include "Anthony.h"
#define pb push_back
#define eb emplace_back
using namespace std;
int n,m;
vector<vector<pair<int,int>>> g;
vector<int> seq={0,1,0,0,1,1};
vector<int> Mark1();
vector<int> Mark2();
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V){
n=N, m=M;
g.resize(n);
for(int i=0;i<m;i++){
g[U[i]].eb(V[i],i);
g[V[i]].eb(U[i],i);
}
if(A>=3) return Mark1();
return Mark2();
}
vector<int> Mark1(){
vector<int> dpth(n);
vector<bool> vis(n);
vector<int> ans(m);
queue<int> bfs;
bfs.push(0);
dpth[0]=0;
vis[0]=1;
while(!bfs.empty()){
int u=bfs.front();
bfs.pop();
for(auto p:g[u]){
int v=p.first, e=p.second;
if(!vis[v]){
vis[v]=1;
bfs.push(v);
dpth[v]=dpth[u]+1;
ans[e]=dpth[v]%3;
}
else{
if(dpth[v]==dpth[u]) ans[e]=(dpth[v]+1)%3;
else ans[e]=max(dpth[v],dpth[u])%3;
}
}
}
return ans;
}
vector<int> Mark2(){
vector<bool> vis(n);
vector<int> ans(m);
queue<pair<int,int>> bfs;
bfs.push({0,0});
vis[0]=1;
while(!bfs.empty()){
int u=bfs.front().first, col=bfs.front().second;
bfs.pop();
for(auto p:g[u]){
int v=p.first, e=p.second;
if(vis[v]) continue;
vis[v]=1;
if(g[u].size()<=2){
ans[e]=(col+1)%6;
bfs.push({v,ans[e]});
}
else{
ans[e]=seq[col]^1;
bfs.push({v,ans[e]});
}
}
}
for(int i=0;i<m;i++) ans[i]=seq[ans[i]];
return ans;
}
#include <bits/stdc++.h>
#include "Catherine.h"
#define pb push_back
#define x first
#define y second
using namespace std;
int a;
int prv=-1;
bool trying=true;
int cnt=0;
vector<int> sq;
void Init(int A, int B){
a=A;
}
int Move1(vector<int> arr);
int Move2(vector<int> arr);
int Move(vector<int> arr){
if(a>=3) return Move1(arr);
return Move2(arr);
}
int Move1(vector<int> arr){
set<int> st={0,1,2};
for(int i=0;i<3;i++) if(arr[i]==0) st.erase(i);
if(st.size()==1) return *st.begin();
if(*next(st.begin())-*st.begin()==1) return *st.begin();
return 2;
}
int Move2(vector<int> arr){
if(trying){
cnt++;
if(cnt==1){
int sum=arr[0]+arr[1];
if(sum>2){
trying=false;
if(arr[0]==1){
prv=0;
return 0;
}
prv=1;
return 1;
}
else{
for(int i=0;i<arr[0];i++) sq.pb(0);
for(int i=0;i<arr[1];i++) sq.pb(1);
prv=sq.back();
if(sum==1) trying=false;
return prv;
}
}
else{
int sum=arr[0]+arr[1];
if(sum>=2 || sum==0){
trying=false;
if(arr[prv]==0){
sq.pop_back();
return -1;
}
else{
prv^=1;
return prv;
}
}
else{
sq.pb((int)(arr[0]==0));
if(cnt<4){
prv=sq.back();
return prv;
}
else{
trying=false;
if(sq==vector<int>{0,1,0,0,1} || sq==vector<int>{1,0,0,1,1} || sq==vector<int>{0,0,1,1,0} || sq==vector<int>{0,1,1,0,1} || sq==vector<int>{1,1,0,1,0} || sq==vector<int>{1,0,1,0,0}){
sq.pop_back();
sq.pop_back();
return -1;
}
else{
prv=sq.back();
return prv;
}
}
}
}
}
if(arr[0]+arr[1]==1){
prv=(arr[0]==0);
return prv;
}
prv^=1;
return prv;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
15708 KB |
Output is correct |
2 |
Correct |
8 ms |
644 KB |
Output is correct |
3 |
Correct |
47 ms |
14936 KB |
Output is correct |
4 |
Correct |
71 ms |
16856 KB |
Output is correct |
5 |
Correct |
72 ms |
16892 KB |
Output is correct |
6 |
Correct |
56 ms |
15572 KB |
Output is correct |
7 |
Correct |
56 ms |
15744 KB |
Output is correct |
8 |
Correct |
66 ms |
16144 KB |
Output is correct |
9 |
Correct |
65 ms |
16124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
15708 KB |
Output is correct |
2 |
Correct |
8 ms |
644 KB |
Output is correct |
3 |
Correct |
47 ms |
14936 KB |
Output is correct |
4 |
Correct |
71 ms |
16856 KB |
Output is correct |
5 |
Correct |
72 ms |
16892 KB |
Output is correct |
6 |
Correct |
56 ms |
15572 KB |
Output is correct |
7 |
Correct |
56 ms |
15744 KB |
Output is correct |
8 |
Correct |
66 ms |
16144 KB |
Output is correct |
9 |
Correct |
65 ms |
16124 KB |
Output is correct |
10 |
Correct |
50 ms |
13408 KB |
Output is correct |
11 |
Correct |
50 ms |
13660 KB |
Output is correct |
12 |
Correct |
51 ms |
13536 KB |
Output is correct |
13 |
Correct |
51 ms |
13560 KB |
Output is correct |
14 |
Correct |
56 ms |
13916 KB |
Output is correct |
15 |
Correct |
60 ms |
14084 KB |
Output is correct |
16 |
Correct |
64 ms |
16244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
13304 KB |
Output is correct |
2 |
Correct |
8 ms |
792 KB |
Output is correct |
3 |
Correct |
45 ms |
12792 KB |
Output is correct |
4 |
Correct |
72 ms |
14556 KB |
Output is correct |
5 |
Correct |
67 ms |
14760 KB |
Output is correct |
6 |
Correct |
51 ms |
13416 KB |
Output is correct |
7 |
Correct |
53 ms |
13420 KB |
Output is correct |
8 |
Correct |
60 ms |
13948 KB |
Output is correct |
9 |
Correct |
64 ms |
13976 KB |
Output is correct |
10 |
Correct |
57 ms |
13692 KB |
Output is correct |
11 |
Correct |
56 ms |
13684 KB |
Output is correct |
12 |
Correct |
63 ms |
13684 KB |
Output is correct |
13 |
Correct |
57 ms |
13820 KB |
Output is correct |
14 |
Correct |
65 ms |
13972 KB |
Output is correct |
15 |
Correct |
62 ms |
13980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
13304 KB |
Output is correct |
2 |
Correct |
8 ms |
792 KB |
Output is correct |
3 |
Correct |
45 ms |
12792 KB |
Output is correct |
4 |
Correct |
72 ms |
14556 KB |
Output is correct |
5 |
Correct |
67 ms |
14760 KB |
Output is correct |
6 |
Correct |
51 ms |
13416 KB |
Output is correct |
7 |
Correct |
53 ms |
13420 KB |
Output is correct |
8 |
Correct |
60 ms |
13948 KB |
Output is correct |
9 |
Correct |
64 ms |
13976 KB |
Output is correct |
10 |
Correct |
57 ms |
13692 KB |
Output is correct |
11 |
Correct |
56 ms |
13684 KB |
Output is correct |
12 |
Correct |
63 ms |
13684 KB |
Output is correct |
13 |
Correct |
57 ms |
13820 KB |
Output is correct |
14 |
Correct |
65 ms |
13972 KB |
Output is correct |
15 |
Correct |
62 ms |
13980 KB |
Output is correct |
16 |
Correct |
51 ms |
11688 KB |
Output is correct |
17 |
Correct |
49 ms |
11676 KB |
Output is correct |
18 |
Correct |
51 ms |
11512 KB |
Output is correct |
19 |
Correct |
48 ms |
11520 KB |
Output is correct |
20 |
Correct |
54 ms |
12272 KB |
Output is correct |
21 |
Correct |
54 ms |
12448 KB |
Output is correct |
22 |
Correct |
62 ms |
14188 KB |
Output is correct |
23 |
Correct |
51 ms |
11800 KB |
Output is correct |
24 |
Correct |
50 ms |
11656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1136 KB |
Output is correct |
2 |
Correct |
8 ms |
780 KB |
Output is correct |
3 |
Correct |
10 ms |
1260 KB |
Output is correct |
4 |
Correct |
10 ms |
1128 KB |
Output is correct |
5 |
Correct |
10 ms |
1036 KB |
Output is correct |
6 |
Correct |
10 ms |
1128 KB |
Output is correct |
7 |
Correct |
10 ms |
1036 KB |
Output is correct |
8 |
Correct |
10 ms |
1136 KB |
Output is correct |
9 |
Correct |
10 ms |
1132 KB |
Output is correct |
10 |
Correct |
10 ms |
1136 KB |
Output is correct |
11 |
Correct |
10 ms |
1036 KB |
Output is correct |
12 |
Correct |
10 ms |
1248 KB |
Output is correct |
13 |
Correct |
10 ms |
1120 KB |
Output is correct |
14 |
Correct |
10 ms |
1132 KB |
Output is correct |
15 |
Correct |
10 ms |
1124 KB |
Output is correct |
16 |
Correct |
10 ms |
1260 KB |
Output is correct |
17 |
Correct |
10 ms |
1036 KB |
Output is correct |
18 |
Correct |
10 ms |
1256 KB |
Output is correct |
19 |
Correct |
10 ms |
1228 KB |
Output is correct |
20 |
Correct |
10 ms |
1048 KB |
Output is correct |
21 |
Correct |
10 ms |
1124 KB |
Output is correct |
22 |
Correct |
10 ms |
1132 KB |
Output is correct |
23 |
Correct |
10 ms |
1136 KB |
Output is correct |
24 |
Correct |
10 ms |
1256 KB |
Output is correct |
25 |
Correct |
11 ms |
1112 KB |
Output is correct |
26 |
Correct |
10 ms |
1120 KB |
Output is correct |
27 |
Correct |
10 ms |
1108 KB |
Output is correct |
28 |
Correct |
10 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
11392 KB |
Output is correct |
2 |
Correct |
55 ms |
12072 KB |
Output is correct |
3 |
Correct |
8 ms |
784 KB |
Output is correct |
4 |
Correct |
42 ms |
11592 KB |
Output is correct |
5 |
Correct |
62 ms |
13064 KB |
Output is correct |
6 |
Correct |
60 ms |
12952 KB |
Output is correct |
7 |
Correct |
50 ms |
12116 KB |
Output is correct |
8 |
Correct |
50 ms |
12088 KB |
Output is correct |
9 |
Correct |
59 ms |
13096 KB |
Output is correct |
10 |
Correct |
60 ms |
12972 KB |
Output is correct |
11 |
Correct |
61 ms |
13084 KB |
Output is correct |
12 |
Correct |
64 ms |
13100 KB |
Output is correct |
13 |
Correct |
60 ms |
13080 KB |
Output is correct |
14 |
Correct |
60 ms |
13196 KB |
Output is correct |
15 |
Correct |
68 ms |
12968 KB |
Output is correct |
16 |
Correct |
63 ms |
12876 KB |
Output is correct |
17 |
Correct |
56 ms |
12692 KB |
Output is correct |
18 |
Correct |
57 ms |
12688 KB |
Output is correct |
19 |
Correct |
57 ms |
12724 KB |
Output is correct |
20 |
Correct |
57 ms |
12708 KB |
Output is correct |
21 |
Correct |
55 ms |
12580 KB |
Output is correct |
22 |
Correct |
61 ms |
12712 KB |
Output is correct |
23 |
Correct |
49 ms |
11776 KB |
Output is correct |
24 |
Correct |
50 ms |
11860 KB |
Output is correct |
25 |
Correct |
49 ms |
12104 KB |
Output is correct |
26 |
Correct |
51 ms |
12092 KB |
Output is correct |
27 |
Correct |
55 ms |
12468 KB |
Output is correct |
28 |
Correct |
55 ms |
12496 KB |
Output is correct |
29 |
Correct |
54 ms |
12584 KB |
Output is correct |
30 |
Correct |
59 ms |
12588 KB |
Output is correct |
31 |
Correct |
51 ms |
11932 KB |
Output is correct |
32 |
Correct |
54 ms |
11924 KB |
Output is correct |
33 |
Correct |
51 ms |
12076 KB |
Output is correct |
34 |
Correct |
49 ms |
12084 KB |
Output is correct |
35 |
Correct |
55 ms |
12496 KB |
Output is correct |
36 |
Correct |
57 ms |
12364 KB |
Output is correct |
37 |
Correct |
54 ms |
12492 KB |
Output is correct |
38 |
Correct |
55 ms |
12488 KB |
Output is correct |
39 |
Correct |
55 ms |
12504 KB |
Output is correct |
40 |
Correct |
54 ms |
12496 KB |
Output is correct |
41 |
Correct |
57 ms |
12364 KB |
Output is correct |
42 |
Correct |
56 ms |
12528 KB |
Output is correct |
43 |
Correct |
59 ms |
12524 KB |
Output is correct |
44 |
Correct |
56 ms |
12620 KB |
Output is correct |
45 |
Correct |
63 ms |
12524 KB |
Output is correct |
46 |
Correct |
54 ms |
12536 KB |
Output is correct |
47 |
Correct |
52 ms |
12364 KB |
Output is correct |
48 |
Correct |
52 ms |
12368 KB |
Output is correct |
49 |
Correct |
52 ms |
12248 KB |
Output is correct |
50 |
Correct |
54 ms |
12488 KB |
Output is correct |
51 |
Correct |
49 ms |
11988 KB |
Output is correct |
52 |
Correct |
54 ms |
11980 KB |
Output is correct |
53 |
Correct |
53 ms |
12248 KB |
Output is correct |
54 |
Correct |
50 ms |
12016 KB |
Output is correct |
55 |
Correct |
50 ms |
12016 KB |
Output is correct |
56 |
Correct |
51 ms |
11996 KB |
Output is correct |
57 |
Correct |
50 ms |
12040 KB |
Output is correct |
58 |
Correct |
50 ms |
12040 KB |
Output is correct |
59 |
Correct |
51 ms |
12028 KB |
Output is correct |
60 |
Correct |
51 ms |
11980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
11636 KB |
Output is correct |
2 |
Correct |
51 ms |
11636 KB |
Output is correct |
3 |
Correct |
8 ms |
784 KB |
Output is correct |
4 |
Correct |
45 ms |
11260 KB |
Output is correct |
5 |
Correct |
66 ms |
12720 KB |
Output is correct |
6 |
Correct |
60 ms |
12588 KB |
Output is correct |
7 |
Correct |
54 ms |
11544 KB |
Output is correct |
8 |
Correct |
50 ms |
11564 KB |
Output is correct |
9 |
Correct |
60 ms |
12876 KB |
Output is correct |
10 |
Correct |
65 ms |
12876 KB |
Output is correct |
11 |
Correct |
63 ms |
12964 KB |
Output is correct |
12 |
Correct |
63 ms |
12976 KB |
Output is correct |
13 |
Correct |
60 ms |
13108 KB |
Output is correct |
14 |
Correct |
64 ms |
13004 KB |
Output is correct |
15 |
Correct |
63 ms |
13084 KB |
Output is correct |
16 |
Correct |
61 ms |
13104 KB |
Output is correct |
17 |
Correct |
57 ms |
12708 KB |
Output is correct |
18 |
Correct |
61 ms |
12716 KB |
Output is correct |
19 |
Correct |
55 ms |
12728 KB |
Output is correct |
20 |
Correct |
59 ms |
12712 KB |
Output is correct |
21 |
Correct |
55 ms |
12716 KB |
Output is correct |
22 |
Correct |
61 ms |
12628 KB |
Output is correct |
23 |
Correct |
50 ms |
11928 KB |
Output is correct |
24 |
Correct |
48 ms |
11932 KB |
Output is correct |
25 |
Correct |
50 ms |
12096 KB |
Output is correct |
26 |
Correct |
51 ms |
12088 KB |
Output is correct |
27 |
Correct |
55 ms |
12488 KB |
Output is correct |
28 |
Correct |
55 ms |
12608 KB |
Output is correct |
29 |
Correct |
55 ms |
12604 KB |
Output is correct |
30 |
Correct |
54 ms |
12364 KB |
Output is correct |
31 |
Correct |
50 ms |
11936 KB |
Output is correct |
32 |
Correct |
49 ms |
11884 KB |
Output is correct |
33 |
Correct |
53 ms |
12108 KB |
Output is correct |
34 |
Correct |
52 ms |
12092 KB |
Output is correct |
35 |
Correct |
55 ms |
12484 KB |
Output is correct |
36 |
Correct |
55 ms |
12372 KB |
Output is correct |
37 |
Correct |
55 ms |
12488 KB |
Output is correct |
38 |
Correct |
54 ms |
12492 KB |
Output is correct |
39 |
Correct |
57 ms |
12236 KB |
Output is correct |
40 |
Correct |
60 ms |
12480 KB |
Output is correct |
41 |
Correct |
56 ms |
12528 KB |
Output is correct |
42 |
Correct |
59 ms |
12656 KB |
Output is correct |
43 |
Correct |
57 ms |
12532 KB |
Output is correct |
44 |
Correct |
57 ms |
12540 KB |
Output is correct |
45 |
Correct |
60 ms |
12652 KB |
Output is correct |
46 |
Correct |
62 ms |
12536 KB |
Output is correct |
47 |
Correct |
55 ms |
12364 KB |
Output is correct |
48 |
Correct |
54 ms |
12220 KB |
Output is correct |
49 |
Correct |
53 ms |
12360 KB |
Output is correct |
50 |
Correct |
53 ms |
12480 KB |
Output is correct |
51 |
Correct |
53 ms |
11988 KB |
Output is correct |
52 |
Correct |
50 ms |
11988 KB |
Output is correct |
53 |
Correct |
49 ms |
12004 KB |
Output is correct |
54 |
Correct |
53 ms |
11996 KB |
Output is correct |
55 |
Correct |
50 ms |
11988 KB |
Output is correct |
56 |
Correct |
49 ms |
12020 KB |
Output is correct |
57 |
Correct |
50 ms |
12052 KB |
Output is correct |
58 |
Correct |
51 ms |
11988 KB |
Output is correct |
59 |
Correct |
51 ms |
11860 KB |
Output is correct |
60 |
Correct |
54 ms |
12056 KB |
Output is correct |