#include "Anthony.h"
#include <vector>
#include<iostream>
#include<cassert>
#define pb push_back
#define st first
#define nd second
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
namespace {
vi vis, col;
vector<vector<pii> > E;
vector<int> wzo={0,0,0,1,1,0,1};
void dfs(int v, int i, int zmi, int co, int czy, int p){
//i, zmi - pozycje w ciagu, co-krawedz do ojca, czy=czy ojciec mial wiele dzieci
vis[v]=1;
int cnt=0;
for(pii u:E[v])if(!vis[u.st])cnt++;
for(pii u:E[v]){
if(!vis[u.st]){
if(cnt==1){
col[u.nd]=wzo[i]^zmi;
dfs(u.st,(i+1)%7, zmi, col[u.nd], 0, v);
}
else{
col[u.nd]=co^1;
dfs(u.st, 1, co^1, co^1, 1, v);
}
}
else if(u.st!=p)col[u.nd]=2;
}
}
} // namespace
std::vector<int> Mark(int N, int M, int A, int B,
std::vector<int> U, std::vector<int> V) {
vis.resize(N);
E.resize(N);
col.resize(M);
for(int i=0; i<M; i++){
E[U[i]].pb({V[i], i});
E[V[i]].pb({U[i], i});
}
dfs(0, 0, 0, 0, 0, -1);
for(int i=0; i<M; i++){
cerr<<U[i]<<" "<<V[i]<<" "<<col[i]<<"\n";
}
return col;
}
#include "Catherine.h"
#include <vector>
#include<iostream>
#include<cassert>
#include<algorithm>
#define pb push_back
#define st first
#define nd second
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
namespace {
int A, B;
int czy_pocz, lst, czy_dobrze;
vector<int> co;
} // namespace
void Init(int A, int B) {
co.clear();
::A = A;
::B = B;
czy_pocz=1;
czy_dobrze=0;
}
int Move(std::vector<int> y) {
for(int i:y)cerr<<i<<" ";
cerr<<endl;
if(1-czy_pocz+y[0]+y[1]>=3){
czy_dobrze=1;
if(czy_pocz){
czy_pocz=0;
if(y[0]<=1)return 0;
else return 1;
}
else{
if(y[lst])return lst^1;
else return -1;
}
}
if(czy_pocz==1){
lst=!!y[1];
co.pb(!!y[1]);
czy_pocz=0;
return !!y[1];
}
if(czy_dobrze){
lst=y[1];
return y[1];
}
if(y[0]+y[1]==0){
czy_dobrze=1;
return -1;
}
co.pb(y[1]);
if(co.size()==7){
while(co[0]==co.back()){
co.pb(co[0]);
reverse(co.begin(), co.end());
co.pop_back();
reverse(co.begin(), co.end());
}
cerr<<"a\n";
vector<int> V;
int cnt=0;
for(int i=0; i<7; i++){
cnt++;
if(i==6 || co[i]!=co[i+1]){
V.pb(cnt);
cnt=0;
}
}
czy_dobrze=1;
if(V==vi({3,2,1,1})
||V==vi({2,1,1,3})||V==vi({1,1,3,2})||V==vi({1,3,2,1})){
return -1;
}
else{
lst=y[1];
return y[1];
}
}
lst=y[1];
return y[1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
141 ms |
16468 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
141 ms |
16468 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
143 ms |
13932 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
143 ms |
13932 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
864 KB |
Output is correct |
2 |
Correct |
1 ms |
520 KB |
Output is correct |
3 |
Correct |
5 ms |
860 KB |
Output is correct |
4 |
Correct |
7 ms |
900 KB |
Output is correct |
5 |
Correct |
7 ms |
908 KB |
Output is correct |
6 |
Correct |
7 ms |
860 KB |
Output is correct |
7 |
Correct |
7 ms |
908 KB |
Output is correct |
8 |
Correct |
6 ms |
900 KB |
Output is correct |
9 |
Correct |
7 ms |
968 KB |
Output is correct |
10 |
Correct |
7 ms |
856 KB |
Output is correct |
11 |
Correct |
5 ms |
900 KB |
Output is correct |
12 |
Incorrect |
5 ms |
908 KB |
Wrong Answer [5] |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
141 ms |
11700 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
138 ms |
11748 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |