Submission #651399

# Submission time Handle Problem Language Result Execution time Memory
651399 2022-10-18T16:57:08 Z BidoTeima Izbori (COCI17_izbori) C++17
0 / 80
49 ms 65536 KB
/*
ID: BidoTeima
LANG: C++11
TASK: Izbori
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void moo(string filename);
void ACPLS(string str = "")
{
    if(str=="NOF")return;
    if(str.size())
        moo(str);
    else{
        #ifndef ONLINE_JUDGE
            freopen("output.txt", "w", stdout);
            freopen("input.txt", "r", stdin);
        #endif
    }
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void moo(string fileName){
    freopen((fileName+".in").c_str(),"r",stdin);
    freopen((fileName+".out").c_str(),"w",stdout);
}
#define tc         \
    int tttttt/*,subtask*/;    \
    cin >> tttttt/* >> subtask*/; \
    while (tttttt--)/*end
*/    

int main()
{
    ACPLS("");
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<int>>a(n,vector<int>(m));
    int f[m+1]={0};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin>>a[i][j];
            if(j == 0)
                ++f[a[i][j]];
        }
        reverse(a[i].begin(),a[i].end());
    }
    int winner = max_element(f+1,f+m+1) - f;
    cout<<winner<<'\n';
    bool vis[m+1]={0};
    int ans = 0;
    while(winner != k){
        vis[winner]=1;
        for(int i = 0; i < n; i++){
            while(vis[a[i].back()]){
                --f[a[i].back()];
                a[i].pop_back();
                ++f[a[i].back()];
            }
        }
        winner = max_element(f+1,f+m+1) - f;
        ++ans;
    }
    cout<<ans<<'\n';
}

Compilation message

izbori.cpp: In function 'void ACPLS(std::string)':
izbori.cpp:17:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |             freopen("output.txt", "w", stdout);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
izbori.cpp:18:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |             freopen("input.txt", "r", stdin);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
izbori.cpp: In function 'void moo(std::string)':
izbori.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((fileName+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
izbori.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((fileName+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 65536 KB Execution killed with signal 9
2 Runtime error 42 ms 65536 KB Execution killed with signal 9
3 Runtime error 37 ms 65536 KB Execution killed with signal 9
4 Runtime error 45 ms 65536 KB Execution killed with signal 9
5 Runtime error 38 ms 65536 KB Execution killed with signal 9
6 Runtime error 38 ms 65536 KB Execution killed with signal 9
7 Runtime error 36 ms 65536 KB Execution killed with signal 9
8 Runtime error 40 ms 65536 KB Execution killed with signal 9
9 Runtime error 47 ms 65536 KB Execution killed with signal 9
10 Runtime error 41 ms 65536 KB Execution killed with signal 9
11 Runtime error 39 ms 65536 KB Execution killed with signal 9
12 Runtime error 47 ms 65536 KB Execution killed with signal 9
13 Runtime error 40 ms 65536 KB Execution killed with signal 9
14 Runtime error 39 ms 65536 KB Execution killed with signal 9
15 Runtime error 43 ms 65536 KB Execution killed with signal 9
16 Runtime error 35 ms 65536 KB Execution killed with signal 9
17 Runtime error 41 ms 65536 KB Execution killed with signal 9
18 Runtime error 42 ms 65536 KB Execution killed with signal 9
19 Runtime error 35 ms 65536 KB Execution killed with signal 9
20 Runtime error 49 ms 65536 KB Execution killed with signal 9