#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){
lst=0;
return 0;
}
else{
lst=1;
return 1;
}
}
else{
if(y[lst]){
lst^=1;
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 |
151 ms |
15880 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
151 ms |
15880 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
140 ms |
13616 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
140 ms |
13616 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
896 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
144 ms |
11260 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
142 ms |
11276 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |