QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#234765 | #7636. Fair Elections | ucup-team1004 | WA | 31ms | 521720kb | C++14 | 1.5kb | 2023-11-01 21:58:54 | 2023-11-01 21:58:54 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'