Submission #648506

# Submission time Handle Problem Language Result Execution time Memory
648506 2022-10-06T18:37:55 Z inksamurai Izbori (COCI17_izbori) C++17
48 / 80
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3Rz7lEu ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
// e

const int mod=1000000007;

signed main(){
_3Rz7lEu;
	int n,m,id;
	cin>>n>>m>>id;
	id-=1;
	vec(vi) a(n,vi(m));
	rep(i,n){
		rep(j,m){
			cin>>a[i][j];
			a[i][j]--;
		}
	}
	int cnt=0;
	int p0=-1,p1=-1;
	while(m){
		std::map<int,int> mp;
		rep(i,n){
			mp[a[i][0]]+=1;	
		}
		pii np={-1,-1};
		for(auto p:mp){
			if(p.se>np.se)np=p;
		}
		if(cnt==0)p0=np.fi+1;
		if(np.fi==id){
			p1=cnt;
			break;
		}else{
			rep(i,n){
				rep(j,m){
					if(a[i][j]==np.fi){
						a[i].erase(a[i].begin()+j);
						break;
					}
				}
			}
		}
		cnt+=1;
		m-=1;
	}
	cout<<p0<<"\n"<<p1<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Partially correct 1 ms 316 KB Partially correct
4 Partially correct 1 ms 212 KB Partially correct
5 Partially correct 1 ms 316 KB Partially correct
6 Partially correct 1 ms 212 KB Partially correct
7 Partially correct 0 ms 212 KB Partially correct
8 Partially correct 1 ms 212 KB Partially correct
9 Partially correct 1 ms 212 KB Partially correct
10 Partially correct 1 ms 212 KB Partially correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Partially correct 1 ms 324 KB Partially correct
14 Partially correct 1 ms 212 KB Partially correct
15 Partially correct 1 ms 212 KB Partially correct
16 Partially correct 1 ms 212 KB Partially correct
17 Partially correct 1 ms 212 KB Partially correct
18 Partially correct 1 ms 316 KB Partially correct
19 Partially correct 1 ms 212 KB Partially correct
20 Partially correct 1 ms 212 KB Partially correct