# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44564 | 2018-04-03T09:47:31 Z | heon | Izbori (COCI17_izbori) | C++11 | 3 ms | 928 KB |
#include<iostream> #include<algorithm> #include<vector> using namespace std; vector <int> v1; vector <int> v2; int arr[101][16]; int arr2[16]; int arr3[16]; bool anotherOne[16]; int zup,kan,k; int sol = 0; int num = 0; int rj = 0,rj2 = 0; int winner = 0,winner2 = 0; int thei = 0; int lowest = 999; bool game = true; int sortiraj(){ int help1 = 0; int help2 = 0; for(int i = 0; i < v1.size()-1; i++){ for(int j = i+1; j < v1.size(); j++){ if(v1[i] > v1[j]){ help1 = v1[i]; v1[i] = v1[j]; v1[j] = help1; help2 = v2[i]; v2[i] = v2[j]; v2[j] = help2; } } } } int Solution(){ for(int i = 0; i < kan; i++){ if(!anotherOne[i]) sol++; } return sol; } int findWinner(){ for(int i = 0; i < kan; i++){ arr3[i] = 0; } for(int i = 0; i < zup; i++){ for(int j = 0; j < kan; j++){ if(anotherOne[arr[i][j]-1]){ arr3[arr[i][j]-1]++; break; } } } rj2 = 0; winner2 = 0; for(int i = 0; i < kan; i++){ if(arr3[i] > rj2){ rj2 = arr3[i]; winner2 = i+1; } } return winner2; } int main(){ cin >> zup >> kan >> k; for(int i = 0; i < kan; i++){ arr2[i] = 0; arr3[i] = 0; anotherOne[i] = true; } for(int i = 0; i < zup; i++){ for(int j = 0; j < kan; j++){ cin >> arr[i][j]; } arr2[arr[i][0]-1]++; arr3[arr[i][0]-1]++; } for(int i = 0; i < zup; i++){ for(int j = 0; j < kan; j++){ if(arr[i][j] == k){ v1.push_back(j); v2.push_back(i); break; } } } sortiraj(); while(game){ for(int i = 0; i < kan; i++){ anotherOne[i] = true; } for(int j = 0; j < kan; j++){ if(arr[v2[0]][j] == k){ break; } anotherOne[arr[v2[0]][j]-1] = false; } if(findWinner() == k){ game = false; } v1.erase(v1.begin()); v2.erase(v2.begin()); } for(int i = 0; i < kan; i++){ if(arr2[i] > rj){ rj = arr2[i]; winner = i+1; } } cout << winner << endl << Solution(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 2 ms | 376 KB | Partially correct |
2 | Partially correct | 2 ms | 476 KB | Partially correct |
3 | Correct | 3 ms | 588 KB | Output is correct |
4 | Partially correct | 2 ms | 756 KB | Partially correct |
5 | Partially correct | 2 ms | 756 KB | Partially correct |
6 | Correct | 2 ms | 796 KB | Output is correct |
7 | Correct | 2 ms | 864 KB | Output is correct |
8 | Correct | 2 ms | 864 KB | Output is correct |
9 | Partially correct | 2 ms | 864 KB | Partially correct |
10 | Partially correct | 2 ms | 864 KB | Partially correct |
11 | Correct | 2 ms | 864 KB | Output is correct |
12 | Partially correct | 2 ms | 888 KB | Partially correct |
13 | Partially correct | 2 ms | 888 KB | Partially correct |
14 | Correct | 3 ms | 888 KB | Output is correct |
15 | Correct | 2 ms | 888 KB | Output is correct |
16 | Correct | 2 ms | 888 KB | Output is correct |
17 | Partially correct | 2 ms | 888 KB | Partially correct |
18 | Correct | 2 ms | 924 KB | Output is correct |
19 | Partially correct | 2 ms | 924 KB | Partially correct |
20 | Partially correct | 3 ms | 928 KB | Partially correct |