#include "Anthony.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
using namespace std;
namespace {
int FunctionExample(int i, int A) {
return i % A;
}
} // namespace
vector<int> Mark(int n,int m, int a, int b,vector<int> U,vector<int> V) {
vector<int> X(m);
vector<int>lvl(n+1,1e9),vis(n,0);
vector<vector<pii>>adj(n);
for(int i=0;i<m;i++){
adj[U[i]].pb({V[i],i}),adj[V[i]].pb({U[i],i});
}
queue<int>q;
lvl[0]=0;
q.push(0);
while(!q.empty()){
int cur=q.front();
q.pop();
if(vis[cur])continue;
vis[cur]=1;
for(auto i:adj[cur])if(!vis[i.f]&&lvl[i.f]>lvl[cur]+1){
lvl[i.f]=lvl[cur]+1;
q.push(i.f);
}
}
if(a>=3){
for(int i=0;i<n;i++)for(auto j:adj[i]){
if(lvl[j.f]<lvl[i])X[j.s]=(lvl[j.f]%3);
else X[j.s]=lvl[i]%3;
}
}
else{
//0 0 1 1 0 1
//1 1 0 1 0 0
vector<int>pat={0,0,1,1,0,1};
vector<int>val(n,0);
int h=0;
function<void(int,int,int)> dfs=[&](int cur,int p,int c){
for(auto i:adj[cur])if(i.f!=p){
if(adj[cur].size()>2-(p==-1))c=0;
if(adj[i.f].size()<=2||adj[cur].size()<=2){
if(c==0){
X[i.s]=val[i.f]=val[cur]^1;
if(val[i.f])c=2;
}
else X[i.s]=val[i.f]=pat[c%6];
dfs(i.f,cur,c+1);
}
else{
X[i.s]=val[i.f]=val[cur]^1;
dfs(i.f,cur,c);
}
}
};
dfs(0,-1,0);
}
return X;
}
#include "Catherine.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
using namespace std;
using namespace std;
namespace {
int a, b;
int variable_example = 0;
int found=0;
deque<int>cor={1,0,1,1,0,0};
deque<int>wro={0,1,0,0,1,1};
vector<int>have;
int st=0,last=0;
}
vector<int>huh;
void Init(int A, int B){
::a = A;
::b = B;
found=0;
st=0;
have.clear();
}
int Move(vector<int> y){
int cnt=0;
for(auto i:y)cnt+=!!i;
if(a>=3){
if(cnt==0)assert(0);
if(cnt==1){
for(int i=0;i<y.size();i++)if(y[i])return i;
}
if(cnt==2){
if(y[0]&&y[2])return 2;
if(y[1]&&y[2])return 1;
if(y[0]&&y[1])return 0;
}
assert(0);
}
else{
if(found){
if((!!y[0])+(!!y[1])!=1)y[last]++;
for(int i=0;i<y.size();i++)if(y[i]==1)return last=i;
}
else{
if(st)y[last]++;
if((y[0]==1)^(y[1]==1)){
found=1;
if(st&&y[last]==1)return -1;
return last=(y[1]==1);
}
if(st)y[last]--;
st=1;
int c=(!!y[1]);
if(!st)have.pb(y[1]>1);
have.pb(c);
int same=0,same2=0;
if(have.size()>6)assert(0);
for(int i=0;i<6;i++){
int yes=1,yes2=1;
for(int j=0;j<have.size();j++){
if(have[j]!=cor[j])yes=0;
if(have[j]!=wro[j])yes2=0;
}
same+=yes;
same2+=yes2;
cor.pb(cor.front());
cor.pop_front();
wro.pb(wro.front());
wro.pop_front();
}
if((same==1||same2==1)&&(same^same2)){
found=1;
if(same==0)return -1;
}
return last=c;
}
}
assert(0);
return -1;
}
Compilation message (stderr)
# 1번째 컴파일 단계
Anthony.cpp:17:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
17 | #pragma GCC optimize ("03,unroll-lopps")
| ^
Anthony.cpp:21:33: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
21 | int FunctionExample(int i, int A) {
| ^
Anthony.cpp:27:71: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
27 | vector<int> Mark(int n,int m, int a, int b,vector<int> U,vector<int> V) {
| ^
Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:60:60: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
60 | function<void(int,int,int)> dfs=[&](int cur,int p,int c){
| ^
# 2번째 컴파일 단계
Catherine.cpp:17:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
17 | #pragma GCC optimize ("03,unroll-lopps")
| ^
Catherine.cpp:30:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
30 | void Init(int A, int B){
| ^
Catherine.cpp:37:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
37 | int Move(vector<int> y){
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |