Submission #928642

# Submission time Handle Problem Language Result Execution time Memory
928642 2024-02-17T00:17:18 Z MilosMilutinovic Stray Cat (JOI20_stray) C++14
Compilation error
0 ms 0 KB
#include "Anthony.h"
#include<bits/stdc++.h>
 
using namespace std;
 
namespace {
const int seq[]={1,0,1,1,0,0};
int n,tot;
int v[40005],nxt[40005],h[20005],d[20005],q[20005],idx[20005];
vector<int> ret;
 
void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot;
}
 
void bfs(){
	for(int i=0;i<n;i++) d[i]=-1;
	int front=0,rear=0;
	q[rear++]=0; d[0]=0;
	while(front<rear){
		int x=q[front];
		for(int p=h[x];p;p=nxt[p]){
			if(d[v[p]]==-1){
				d[v[p]]=d[x]+1;
				q[rear++]=v[p];
			}
		}
		++front;
	}
}

void dfs(int x,int fa,int lst,int idx){
	int ch=0;
	for(int p=h[x];p;p=nxt[p]) if(v[p]!=fa) ch++;
	if(ch==0) return;
	if(ch==1){
		for(int p=h[x];p;p=nxt[p]){
			if(v[p]==fa) continue;
			ret[idx[v[p]]]=(lst^seq[idx]);
			dfs(v[p],x,lst,(idx+1)%6);
		}
	}else{
		for(int p=h[x];p;p=nxt[p]){
			if(v[p]==fa) continue;
			ret[idx[v[p]]]=(x==0?0:ret[idx[x]]])^1;
			dfs(v[p],x,x==0?0:ret[idx[x]]],1);
		}
	}
}
}
 
vector<int> Mark(int n,int m,int a,int b,vector<int> u,vector<int> v){
	::n=n;
	for(int i=0;i<m;i++) addedge(u[i],v[i]);
	if(a>=3){
		bfs();
		vector<int> col(m);
		for(int i=0;i<m;i++) col[i]=min(d[u[i]],d[v[i]])%3;
		return col;
	}else{
		for(int i=0;i<m;i++){
			if(d[u[i]]>d[v[i]]) swap(u[i],v[i]);
			idx[v[i]]=i;
		}
		ret.resize(m);
		dfs(0,0,0);
	}
	return vector<int>(m,0);
}
#include "Catherine.h"
#include<bits/stdc++.h>
 
using namespace std;
 
namespace {
 
int a,b;
}  // namespace
 
void Init(int A,int B){
	a=A; b=B;
}
 
int Move(vector<int> y){
	int cnt=0;
	for(int i=0;i<a;i++) cnt+=(y[i]>0?1:0);
	if(cnt==1){
		for(int i=0;i<a;i++) if(y[i]>0) return i;
	}
	for(int i=0;i<a;i++){
		if(y[i]>0&&y[(i+1)%3]>0) return i;
	}
}

Compilation message

Anthony.cpp: In function 'void {anonymous}::dfs(int, int, int, int)':
Anthony.cpp:40:11: error: invalid types 'int[int]' for array subscript
   40 |    ret[idx[v[p]]]=(lst^seq[idx]);
      |           ^
Anthony.cpp:46:11: error: invalid types 'int[int]' for array subscript
   46 |    ret[idx[v[p]]]=(x==0?0:ret[idx[x]]])^1;
      |           ^
Anthony.cpp:46:34: error: invalid types 'int[int]' for array subscript
   46 |    ret[idx[v[p]]]=(x==0?0:ret[idx[x]]])^1;
      |                                  ^
Anthony.cpp:46:38: error: expected ')' before ']' token
   46 |    ret[idx[v[p]]]=(x==0?0:ret[idx[x]]])^1;
      |                   ~                  ^
      |                                      )
Anthony.cpp:47:29: error: invalid types 'int[int]' for array subscript
   47 |    dfs(v[p],x,x==0?0:ret[idx[x]]],1);
      |                             ^
Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:67:12: error: too few arguments to function 'void {anonymous}::dfs(int, int, int, int)'
   67 |   dfs(0,0,0);
      |            ^
Anthony.cpp:33:6: note: declared here
   33 | void dfs(int x,int fa,int lst,int idx){
      |      ^~~

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:24:1: warning: control reaches end of non-void function [-Wreturn-type]
   24 | }
      | ^