Submission #1087927

# Submission time Handle Problem Language Result Execution time Memory
1087927 2024-09-13T14:33:50 Z idk__ Izbori (COCI17_izbori) C++14
56 / 80
423 ms 460 KB
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define int long long
int a[101][16+5], n, m , k;
vector<int>temp;


int winner(){
    int b[100][16+5]={};
    for(int i = 0;i < n; i++){
        for(int j = 0;j < m; j++){
            b[i][j] = a[i][j];
        }
    }
        for(auto cv : temp){
            for(int i = 0;i < n; i++){
                for(int j = 0;j < m; j++){
                    if(b[i][j]==cv)b[i][j]=-5;
                }
            }
        }
    

    int count=-1, num=-1;
    int cnt[16]={}, poi[n+5]={};
    for(int i = 0;i < n; i++){
        while(true){
            if(b[i][poi[i]]==-5)poi[i]++;
            else break;
            if(poi[i]>m)break;
        }
        int& curr = b[i][poi[i]];
        if(poi[i]>=m)continue;


        cnt[curr]++;
        if(cnt[curr] > count){
            num = curr;
            count=cnt[curr];
        }
        else if(cnt[curr] == count and curr > num){
                num = curr;
                count = cnt[curr];
        }

        }
        
        return  num;
}
pair<int, int>fans = {1000, 1000};
void rec(int i){

    if(i==m+1){
        pair<int, int>f = {temp.size(), winner()};
        if(f.second==k and temp.size() < fans.first)fans = f;
        return;
    }

    rec(i+1);
    temp.push_back(i);
    rec(i+1);
    temp.pop_back();
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m >> k;
    for(int i = 0;i < n; i++){
        for(int j = 0;j < m; j++){
            cin >> a[i][j];
        }
    }

    int ans = winner();
    cout << ans << endl;
    rec(1);
    cout << fans.first << endl;

    
  
  
  
  
  }

Compilation message

izbori.cpp: In function 'void rec(long long int)':
izbori.cpp:57:40: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   57 |         if(f.second==k and temp.size() < fans.first)fans = f;
      |                            ~~~~~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 11 ms 344 KB Partially correct
2 Partially correct 24 ms 348 KB Partially correct
3 Partially correct 5 ms 348 KB Partially correct
4 Correct 55 ms 348 KB Output is correct
5 Correct 10 ms 344 KB Output is correct
6 Partially correct 6 ms 344 KB Partially correct
7 Partially correct 1 ms 348 KB Partially correct
8 Correct 34 ms 348 KB Output is correct
9 Partially correct 36 ms 348 KB Partially correct
10 Partially correct 2 ms 344 KB Partially correct
11 Correct 25 ms 460 KB Output is correct
12 Correct 148 ms 348 KB Output is correct
13 Correct 330 ms 344 KB Output is correct
14 Correct 142 ms 348 KB Output is correct
15 Correct 26 ms 348 KB Output is correct
16 Partially correct 404 ms 348 KB Partially correct
17 Partially correct 151 ms 348 KB Partially correct
18 Incorrect 358 ms 348 KB Output isn't correct
19 Partially correct 423 ms 344 KB Partially correct
20 Correct 394 ms 348 KB Output is correct