답안 #315033

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
315033 2020-10-22T01:04:15 Z thtsshz_bgwrswh CONSUL (info1cup19_consul) C++17
0 / 100
5 ms 256 KB
#pragma GCC optimize("Ofast")
#include "grader.h"
#include<algorithm>
#include<random>
#include<vector>
#include<utility>
#include<map>
using namespace std;
int order[1005];
map<int,int> m;
vector<pair<int,int>> q;
void solve(int n){
	int i;
	for(i=1;i<=n;i++)
		order[i]=i;
	random_shuffle(order,order+n);
	for(i=1;i<=40;i++)
		m[kth(order[i])]++;	
	for(auto x:m)
		q.emplace_back(x.second,x.first);
	sort(q.begin(),q.end());
	reverse(q.begin(),q.end());
	if(n<=50){
		int ans=0,v;
		for(i=0;i<10&&i<(int)q.size();i++){
			int temp=cnt(q[i].second);
			if(temp>ans){
				ans=temp;
				v=q[i].second;
			}
		}
		if(ans>n/3)
			say_answer(v);
		else
			say_answer(-1);
	}
	else{
		int ans=0,v;
		for(i=0;i<20&&i<(int)q.size();i++){
			int temp=cnt(q[i].second);
			if(temp>ans){
				ans=temp;
				v=q[i].second;
			}
		}
		if(ans>n/3)
			say_answer(v);
		else
			say_answer(-1);
	}
}

Compilation message

consul.cpp: In function 'void solve(int)':
consul.cpp:47:14: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |    say_answer(v);
      |    ~~~~~~~~~~^~~
consul.cpp:33:14: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |    say_answer(v);
      |    ~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Wrong answer
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Wrong answer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 256 KB Wrong answer
2 Halted 0 ms 0 KB -