Submission #1087379

#TimeUsernameProblemLanguageResultExecution timeMemory
1087379kasdoIzbori (COCI17_izbori)C++14
42 / 80
1 ms460 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define speed cin.tie (0) -> sync_with_stdio (0);ios_base::sync_with_stdio(false);cin.tie(0);
void solve()
{
    int n, m, k;
    cin>>n>>m>>k;
    int a[n + 5][m + 5];
    
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin>>a[i][j];
        }
    }
    
    bool v[m + 5] = {};
    for(int j=0; j<m; j++)
    {
        pair<int, int> mx = {0, 0};
        int f[m + 5] = {};
        int ans = 1;
        for(int i=0; i<n; i++)
        {
            int idx = i;
            while(idx < n && v[a[idx][j]]) idx++;
            if (idx == n) continue;
            f[a[idx][j]]++;
            
            if (f[a[idx][j]] == mx.first && a[i][j] < mx.second) mx = {f[a[idx][j]], a[i][j]};
            if (f[a[idx][j]] > mx.first) mx = {f[a[idx][j]], a[i][j]};
        }
        
        v[mx.second] = 1;
        if (j == 0) cout<<mx.second<<endl;
        if (mx.second == k)
        {
            cout<<j<<endl;
            break;
        }
    }
}
signed main ()
{
    speed
    // freopen("feast.in", "r", stdin);
    // freopen("feast.out", "w", stdout);

    int _ = 1;
    // cin>>_;

    while(_--) solve();

    return 0;
}

Compilation message (stderr)

izbori.cpp: In function 'void solve()':
izbori.cpp:25:13: warning: unused variable 'ans' [-Wunused-variable]
   25 |         int ans = 1;
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...