#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
namespace {
const int N = (int)20010;
vector<pii> T[N];
vector<int> pattern = {1,1,0,1,0,0};
int dd[N];
} // namespace
int n, m;
vector<int> idx;
int dep[N];
void make1(){
queue<int> que;
for(int i = 0 ; i < n; i ++ ){
dep[i]=-1;
}
for(int i = 0 ; i < m ; i ++ ){
idx[i]=-1;
}
dep[0]=0;
que.push(0);
int nd;
while(!que.empty()){
nd=que.front();
que.pop();
for(auto x : T[nd]){
if(dep[x.fi] == -1){
dep[x.fi]=(dep[nd]+1)%3;
que.push(x.fi);
}
if(idx[x.se] == -1) idx[x.se]=dep[nd];
}
}
}
void dfs0(int u, int par, int bit){
for(auto x : T[u]){
if(x.fi == par) continue;
dd[x.fi]=dd[u]+1;
if(T[x.fi].size() != 2){
idx[x.se]=bit;
}
else{
idx[x.se]=pattern[dd[x.fi] % 6];
}
dfs0(x.fi, u, bit ^ 1);
}
}
void make2(){
dd[0]=0;
dfs0(0, -1, 0);
}
vector<int> Mark(int _n, int _m, int a, int b, vector<int> u, vector<int> v) {
n = _n;
m = _m;
for(int i = 0 ; i < m ; i ++ ){
T[u[i]].push_back(mp(v[i],i));
T[v[i]].push_back(mp(u[i],i));
}
idx.resize(m);
if(a >= 3) make1();
else make2();
return idx;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
namespace {
int A;
vector<int> trav;
int las;
bool know;
vector<int> pattern = {1, 1, 0, 1, 0, 0};
} // namespace
void Init(int a, int b) {
A = a;
trav.clear();
las = -1;
know = false;
}
int move_3(vector<int> y){
for(int d = 0; d < 3; d ++ ){
if(y[d] > 0 && y[(d + 1) % 3] > 0) return d;
}
for(int d = 0; d < 3; d ++ ){
if(y[d] > 0) return d;
}
return -1;
}
int move_2(vector<int> y){
vector<int> g = y;
if(las != -1) g[las] ++ ;
int pick = -1;
if(g[0] + g[1] != 2){
know = true;
trav.clear();
if(g[0] == 1) pick = 0;
else pick = 1;
}
else{
if(know){
if(!trav.empty()){
pick = -1;
las=trav.back();
trav.pop_back();
}
else{
if(y[0] == 1) pick = 0;
else pick = 1;
las=pick;
}
}
else{
if(trav.empty()){
for(int d = 0; d < 2; d ++ ){
for(int p = 0 ; p < y[d]; p ++ ){
trav.push_back(d);
pick=d;
las=d;
}
}
}
else if(trav.size() <= 3){
if(y[0]==1) pick=0;
else pick=1;
las = pick;
trav.push_back(pick);
}
else{
if(y[0] == 1) trav.push_back(0);
else trav.push_back(1);
bool rev = false;
for(int i = 0 ; i < 6 ; i ++ ){
vector<int> g;
for(int j = 0 ; j < 5; j ++ ){
g.push_back(pattern[(i + j) % 6]);
}
if(g == trav) rev = true;
}
if(rev == true){
pick = -1;
trav.pop_back();
trav.erase(trav.begin());
las = trav.back();
trav.pop_back();
}
else{
trav.clear();
if(y[0] == 1) pick = 0;
else pick = 1;
las = pick;
}
know=true;
}
}
}
if(pick == -1 || y[pick] == 0) pick = -1;
return pick;
}
int Move(std::vector<int> y) {
if(A >= 3) return move_3(y);
else{
return move_2(y);
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
15600 KB |
Output is correct |
2 |
Correct |
1 ms |
1024 KB |
Output is correct |
3 |
Correct |
23 ms |
14828 KB |
Output is correct |
4 |
Correct |
34 ms |
16596 KB |
Output is correct |
5 |
Correct |
44 ms |
16556 KB |
Output is correct |
6 |
Correct |
27 ms |
15676 KB |
Output is correct |
7 |
Correct |
31 ms |
15720 KB |
Output is correct |
8 |
Correct |
31 ms |
16448 KB |
Output is correct |
9 |
Correct |
32 ms |
16528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
15600 KB |
Output is correct |
2 |
Correct |
1 ms |
1024 KB |
Output is correct |
3 |
Correct |
23 ms |
14828 KB |
Output is correct |
4 |
Correct |
34 ms |
16596 KB |
Output is correct |
5 |
Correct |
44 ms |
16556 KB |
Output is correct |
6 |
Correct |
27 ms |
15676 KB |
Output is correct |
7 |
Correct |
31 ms |
15720 KB |
Output is correct |
8 |
Correct |
31 ms |
16448 KB |
Output is correct |
9 |
Correct |
32 ms |
16528 KB |
Output is correct |
10 |
Correct |
29 ms |
13900 KB |
Output is correct |
11 |
Correct |
25 ms |
13888 KB |
Output is correct |
12 |
Correct |
25 ms |
13876 KB |
Output is correct |
13 |
Correct |
25 ms |
13868 KB |
Output is correct |
14 |
Correct |
26 ms |
14148 KB |
Output is correct |
15 |
Correct |
31 ms |
14496 KB |
Output is correct |
16 |
Correct |
32 ms |
16416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
13172 KB |
Output is correct |
2 |
Correct |
1 ms |
1024 KB |
Output is correct |
3 |
Correct |
23 ms |
12704 KB |
Output is correct |
4 |
Correct |
32 ms |
14348 KB |
Output is correct |
5 |
Correct |
34 ms |
14408 KB |
Output is correct |
6 |
Correct |
26 ms |
13544 KB |
Output is correct |
7 |
Correct |
26 ms |
13512 KB |
Output is correct |
8 |
Correct |
40 ms |
14252 KB |
Output is correct |
9 |
Correct |
36 ms |
14212 KB |
Output is correct |
10 |
Correct |
34 ms |
13816 KB |
Output is correct |
11 |
Correct |
33 ms |
13956 KB |
Output is correct |
12 |
Correct |
37 ms |
13980 KB |
Output is correct |
13 |
Correct |
34 ms |
13960 KB |
Output is correct |
14 |
Correct |
30 ms |
14260 KB |
Output is correct |
15 |
Correct |
31 ms |
14208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
13172 KB |
Output is correct |
2 |
Correct |
1 ms |
1024 KB |
Output is correct |
3 |
Correct |
23 ms |
12704 KB |
Output is correct |
4 |
Correct |
32 ms |
14348 KB |
Output is correct |
5 |
Correct |
34 ms |
14408 KB |
Output is correct |
6 |
Correct |
26 ms |
13544 KB |
Output is correct |
7 |
Correct |
26 ms |
13512 KB |
Output is correct |
8 |
Correct |
40 ms |
14252 KB |
Output is correct |
9 |
Correct |
36 ms |
14212 KB |
Output is correct |
10 |
Correct |
34 ms |
13816 KB |
Output is correct |
11 |
Correct |
33 ms |
13956 KB |
Output is correct |
12 |
Correct |
37 ms |
13980 KB |
Output is correct |
13 |
Correct |
34 ms |
13960 KB |
Output is correct |
14 |
Correct |
30 ms |
14260 KB |
Output is correct |
15 |
Correct |
31 ms |
14208 KB |
Output is correct |
16 |
Correct |
24 ms |
12096 KB |
Output is correct |
17 |
Correct |
23 ms |
12036 KB |
Output is correct |
18 |
Correct |
24 ms |
11892 KB |
Output is correct |
19 |
Correct |
25 ms |
11860 KB |
Output is correct |
20 |
Correct |
31 ms |
12624 KB |
Output is correct |
21 |
Correct |
26 ms |
12336 KB |
Output is correct |
22 |
Correct |
33 ms |
14260 KB |
Output is correct |
23 |
Correct |
30 ms |
12012 KB |
Output is correct |
24 |
Correct |
28 ms |
11948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1292 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
11180 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
11112 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |