QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#231676 | #7636. Fair Elections | tselmegkh# | WA | 5ms | 3536kb | C++17 | 1.2kb | 2023-10-29 15:22:26 | 2023-10-29 15:22:26 |
Judging History
answer
#include<iostream>
#include<random>
#include<chrono>
#include<vector>
using namespace std;
const int N = 1e4 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[N][3];
int main(){
int n;
cin >> n;
for(int i = 0; i < n; i++){
for(int j = 0; j < 3; j++){
cin >> a[i][j];
}
}
vector<int> win_count(4, 0);
for(int it = 0; it < 20000; it++){
vector<int> cnt(4, 0);
for(int i = 0; i < n; i++){
int x = rng() % 7;
if(x <= 3){
cnt[a[i][0]]++;
} else if(x <= 5){
cnt[a[i][1]]++;
} else {
cnt[a[i][2]]++;
}
}
int mx = 0, winner = -1;
for(int j = 1; j <= 3; j++){
if(cnt[j] > mx){
mx = cnt[j];
winner = j;
}
}
for(int j = 1; j <= 3; j++){
if(cnt[j] == mx)win_count[j]++;
}
}
int mx = 0, res = -1;
for(int i = 1; i <= 3; i++){
if(win_count[i] > mx){
mx = win_count[i];
res = i;
}
}
cout << res << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3488kb
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: 2ms
memory: 3360kb
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: 0ms
memory: 3428kb
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: 2ms
memory: 3536kb
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: 0ms
memory: 3452kb
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: 2ms
memory: 3380kb
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: -100
Wrong Answer
time: 5ms
memory: 3488kb
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:
3
result:
wrong answer 1st numbers differ - expected: '1', found: '3'