QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#234953#7636. Fair Electionsucup-team1004RE 2ms9816kbC++142.4kb2023-11-02 07:05:042023-11-02 07:05:05

Judging History

你现在查看的是最新测评结果

  • [2023-11-02 07:05:05]
  • 评测
  • 测评结果:RE
  • 用时:2ms
  • 内存:9816kb
  • [2023-11-02 07:05:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#ifdef DEBUG
template<typename T>
ostream& operator << (ostream &out,const vector<T> &x){
	if(x.empty())return out<<"[]";
	out<<'['<<x[0];
	for(int i=1,len=x.size();i<len;i++)out<<','<<x[i];
	return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
	cerr<<x<<endl;
}
template<typename T,typename ... S>
void debug(T x,S...y){
	cerr<<x<<' ',debug(y...);
}
#else
#define debug(...) void()
#endif
const int N=5e2+10;
int n,a[3],p[N][3];
struct seg{
	int l,r;
	seg(int x=1,int y=0):l(x),r(y){}
	bool empty()const{
		return l>r;
	}
	seg operator | (const seg &x)const{
		if(empty())return x;
		if(x.empty())return *this;
		return seg(min(l,x.l),max(r,x.r));
	}
	seg operator |= (const seg &x){
		return *this=*this|x;
	}
	seg operator & (const seg &x)const{
		if(empty())return *this;
		if(x.empty())return x;
		return seg(max(l,x.l),min(r,x.r));
	}
	seg operator - (const seg &x)const{
		if(x.empty()||empty())return *this;
		if(x.l>r||x.r<l)return *this;
		else if(r<=x.r)return seg(l,x.l-1);
		else if(x.l<=l)return seg(x.r+1,r);
		else return assert(0),0;
	}
	seg operator - (const int &x)const{
		return seg(l-x,r-x);
	}
}f[N][N][3];
#ifdef DEBUG
ostream& operator << (ostream &out,const seg &x){
	return out<<'('<<x.l<<','<<x.r<<')';
}
#endif
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=0;j<3;j++){
			cin>>p[i][j],p[i][j]--; 
		}
	}
	for(a[0]=0;a[0]<=n;a[0]++){
		for(a[1]=0;a[0]+a[1]<=n;a[1]++){
			a[2]=n-a[0]-a[1];
			int ans=0;
			for(int i=1;i<3;i++)if(a[ans]<a[i])ans=i;
			// debug(f[n+1][a[0]][ans],seg(a[1],a[1]),f[n+1][a[0]][ans]|seg(a[1],a[1]));
			f[n+1][a[0]][ans]|=seg(a[1],a[1]);
		}
		// for(int j=0;j<3;j++){
		// 	debug(n+1,a[0],j,f[n+1][a[0]][j]);
		// }
	}
	for(int i=n;i>=1;i--){
		for(int j=0;j<3;j++){
			if(p[i][j]==0){
				for(int k=0;k<i;k++){
					f[i][k][0]|=(f[i+1][k+1][0]&seg(0,i-1-k))-f[i][k][1]-f[i][k][2];
				}
			}else if(p[i][j]==1){
				for(int k=0;k<i;k++){
					f[i][k][1]|=((f[i+1][k][1]-1)&seg(0,i-1-k))-f[i][k][0]-f[i][k][2];
				}
			}else{
				for(int k=0;k<i;k++){
					f[i][k][2]|=(f[i+1][k][2]&seg(0,i-1-k))-f[i][k][0]-f[i][k][1];
				}
			}
		}
	}
	for(int j=0;j<3;j++){
		if(!f[1][0][j].empty())cout<<j+1<<endl;
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 9816kb

input:

3
3 2 1
1 2 3
2 1 3

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: -100
Runtime Error

input:

5
1 2 3
2 3 1
1 3 2
3 1 2
2 1 3

output:


result: