QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#234765#7636. Fair Electionsucup-team1004WA 31ms521720kbC++141.5kb2023-11-01 21:58:542023-11-01 21:58:54

Judging History

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

  • [2023-11-01 21:58:54]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:521720kb
  • [2023-11-01 21:58:54]
  • 提交

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],f[N][N][N];
int main(){
	cin>>n;
	memset(f,-1,sizeof f);
	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 mx=0;
			for(int i=1;i<3;i++){
				if(a[i]>a[mx])mx=i;
			}
			f[n+1][a[0]][a[1]]=mx;
		}
//		debug(n+1,a[0],ary(f[n+1][a[0]],0,n-a[0]));
	}
	for(int i=n;i>=1;i--){
		for(a[0]=0;a[0]<i;a[0]++){
			for(a[1]=0;a[0]+a[1]<i;a[1]++){
				a[2]=i-1-a[0]-a[1];
//				debug(i,a[0],a[1]);
				for(int j=0;j<3;j++){
//					debug(i,a[0],a[1],a[2],p[i][j]);
					a[p[i][j]]++;
//					debug(i,a[0],a[1],a[2],p[i][j]);
					if(f[i+1][a[0]][a[1]]==p[i][j]){
						a[p[i][j]]--;
						f[i][a[0]][a[1]]=p[i][j];
						break;
					}
					a[p[i][j]]--;
				}
			}
//			debug(i,a[0],ary(f[i][a[0]],0,i-1-a[0]));
		}
	}
	cout<<f[1][0][0]+1<<endl;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 23ms
memory: 521704kb

input:

3
3 2 1
1 2 3
2 1 3

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 27ms
memory: 521536kb

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 24ms
memory: 521664kb

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 16ms
memory: 521720kb

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: 0
Accepted
time: 31ms
memory: 521552kb

input:

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

output:

3

result:

ok 1 number(s): "3"

Test #6:

score: 0
Accepted
time: 3ms
memory: 521516kb

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 4ms
memory: 521672kb

input:

20
1 2 3
2 3 1
1 3 2
3 1 2
2 1 3
1 2 3
3 2 1
1 2 3
1 2 3
3 2 1
3 2 1
3 1 2
2 3 1
1 2 3
2 1 3
3 2 1
3 2 1
1 3 2
1 3 2
3 2 1

output:

1

result:

ok 1 number(s): "1"

Test #8:

score: 0
Accepted
time: 15ms
memory: 521484kb

input:

20
3 2 1
3 1 2
1 2 3
1 3 2
1 3 2
1 2 3
3 1 2
1 3 2
3 2 1
1 3 2
2 1 3
3 1 2
2 3 1
2 1 3
2 3 1
3 1 2
3 1 2
2 1 3
3 1 2
1 2 3

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: 0
Accepted
time: 16ms
memory: 521672kb

input:

20
1 2 3
2 3 1
2 1 3
2 1 3
1 3 2
3 1 2
2 3 1
1 3 2
3 1 2
1 2 3
1 2 3
3 2 1
3 1 2
1 2 3
3 2 1
1 2 3
2 3 1
3 1 2
3 2 1
3 2 1

output:

3

result:

ok 1 number(s): "3"

Test #10:

score: 0
Accepted
time: 12ms
memory: 521668kb

input:

20
3 1 2
3 2 1
1 2 3
1 3 2
1 3 2
2 3 1
1 3 2
2 3 1
1 2 3
3 2 1
1 2 3
3 2 1
1 2 3
1 2 3
3 2 1
2 3 1
2 3 1
1 2 3
2 1 3
2 1 3

output:

1

result:

ok 1 number(s): "1"

Test #11:

score: 0
Accepted
time: 12ms
memory: 521548kb

input:

20
2 1 3
2 1 3
3 1 2
3 2 1
2 1 3
1 2 3
2 3 1
3 1 2
3 1 2
2 3 1
3 2 1
1 3 2
2 1 3
2 1 3
1 2 3
2 3 1
2 3 1
3 2 1
2 1 3
1 3 2

output:

2

result:

ok 1 number(s): "2"

Test #12:

score: -100
Wrong Answer
time: 20ms
memory: 521716kb

input:

10000
1 2 3
2 3 1
1 3 2
3 1 2
2 1 3
1 2 3
3 2 1
1 2 3
1 2 3
3 2 1
3 2 1
3 1 2
2 3 1
1 2 3
2 1 3
3 2 1
3 2 1
1 3 2
1 3 2
3 2 1
3 2 1
3 1 2
1 2 3
1 3 2
1 3 2
1 2 3
3 1 2
1 3 2
3 2 1
1 3 2
2 1 3
3 1 2
2 3 1
2 1 3
2 3 1
3 1 2
3 1 2
2 1 3
3 1 2
1 2 3
1 2 3
2 3 1
2 1 3
2 1 3
1 3 2
3 1 2
2 3 1
1 3 2
3 1 2
...

output:

1

result:

wrong answer 1st numbers differ - expected: '3', found: '1'