제출 #1087929

#제출 시각아이디문제언어결과실행 시간메모리
1087929vjudge1Izbori (COCI17_izbori)C++17
80 / 80
421 ms600 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...