Submission #1088441

# Submission time Handle Problem Language Result Execution time Memory
1088441 2024-09-14T11:51:38 Z vjudge1 Izbori (COCI17_izbori) C++17
0 / 80
1 ms 412 KB
#include <bits/stdc++.h>
#include <fstream>
using namespace std;

#define int long long
#define endl '\n'
const int mxn = 501;
const int mod = 1e8;
// int dx[] = {0 , 0 , 1 , -1};
// int dy[] = {1 , -1 , 0 , 0};
//DFS
//----------------------------------
// vector<int> adj[mxn];
// int n , m;
// bool vis[mxn];
// int P[mxn];
// int rem[mxn];
// void dfs(int i){
//     vis[i] = 1;
//     for(auto j : adj[i]){
//         if(!vis[j]){
//             P[j] = i;
//             dfs(j);
//         }
//     }
//     return;
// }
//----------------------------------
//Seg-Tree
//----------------------------------
// int Tree[1 << (int)(ceil(log2(mxn))) + 1];
// int N = 1 << (int)(ceil(log2(mxn)));
// int l ,r;
// int Search(int i , int lr , int rr){
//     if(lr >= l and rr <= r){
//         return Tree[i];
//     }
//     if(lr > r or rr < l) return -1;
//     return max(Search(i * 2 , lr , (lr + rr) / 2) , Search(i * 2 + 1 , (lr + rr) / 2 + 1 , rr));
// }
// void update(int i){
//     while(i /= 2){
//         Tree[i] = max(Tree[i * 2] , Tree[i * 2 + 1]);
//     }
//     return;
// }
//----------------------------------
//comp
//----------------------------------
// map<int , int>mp;
// map<int , int>pm;
// void comp(set<int>s)
// {
//     int idx = 0;
//     for(auto i : s){
//         mp[i] = idx;
//         pm[idx] = i;
//         idx ++;
//     }
// }
//----------------------------------
signed main() {
  cin.tie(0) -> sync_with_stdio(0);
  int n , m , k;
  cin >> n >> m >> k;
  vector<int>vec[n];
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < m; j ++){
      int x;
      cin >> x;
      vec[i].push_back(x);
    }
  }
  bool used[m + 5] = {};
  int sol = 0;
  bool flag = 1;
  while(true){
    int cnt[m + 5] = {};
    int mx = -1;
    for(int i = 0 ; i < n ; i++){
      if(vec[i].empty()) continue;
      if(mx == -1) mx = vec[i][0];
      cnt[vec[i][0]] ++;
      if(cnt[vec[i][0]] > cnt[mx] || (cnt[mx] == cnt[vec[i][0]] and vec[i][0] < mx)) mx = vec[i][0];
    }
    if(mx != k){
      sol ++;
      for(int i = 0 ; i < n; i++){
        for(int j = 0 ; j < vec[i].size() ; j++){
          if(vec[i][j] == mx){
            vec[i].erase(vec[i].begin() + j);
            break;
          }
        }
      }
    }
    else return cout << sol , 0;
  }
}

Compilation message

izbori.cpp: In function 'int main()':
izbori.cpp:89:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |         for(int j = 0 ; j < vec[i].size() ; j++){
      |                         ~~^~~~~~~~~~~~~~~
izbori.cpp:74:8: warning: unused variable 'used' [-Wunused-variable]
   74 |   bool used[m + 5] = {};
      |        ^~~~
izbori.cpp:76:8: warning: unused variable 'flag' [-Wunused-variable]
   76 |   bool flag = 1;
      |        ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Incorrect 0 ms 412 KB Output isn't correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 1 ms 344 KB Output isn't correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Incorrect 1 ms 348 KB Output isn't correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Incorrect 1 ms 348 KB Output isn't correct
18 Incorrect 0 ms 348 KB Output isn't correct
19 Incorrect 0 ms 348 KB Output isn't correct
20 Incorrect 0 ms 348 KB Output isn't correct