제출 #1360895

#제출 시각아이디문제언어결과실행 시간메모리
1360895jellybeanGuessing Game (EGOI23_guessinggame)C++20
60 / 100
545 ms2412 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define dd(x) cout<<#x<<" is "<<x<<endl;
#define dd2(x,y) cout<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<endl;
typedef pair<int,int> pii;	



signed main(){
	//ios::sync_with_stdio(0); cin.tie(0);
	
	int p,n; cin>>p>>n;
	if(p==1){
		cout<<631<<endl;
		int cnt[320] = {}, val = 316;
		for(int i=0; i<n-1; i++){
			int id; cin>>id;
			int group = id/316;
			cnt[group]++;
			if(group == 316 and cnt[group] == 144){
				cout<<val<<endl;
				val++;
			} else if(cnt[group] == 316){
				cout<<val<<endl;
				val++;
			} else {
				cout<<cnt[group]<<endl;
			}
		}
	} else {
		int cnt[640] = {};
		int a[n];
		int tg = -1;
		for(int i=0; i<n; i++) cin>>a[i];
		for(int i=0; i<n; i++){
			if(a[i] >= 316){
				cnt[a[i]]++;
				if(cnt[a[i]] == 2){
					tg = a[i];
					break;
				}
			}
		}
		
		if(tg != -1){
			for(int i=0; i<n; i++){
				if(a[i] == tg) cout<<i<<" ";
			}
			cout<<endl;
			return 0;
		}
		
		int arr[320][320] = {};
		pii target;
		for(int i=0; i<n; i++){
			if(a[i] >= 316) continue;
			int group = i/316;
			arr[group][a[i]]++;
			if(arr[group][a[i]] == 2){
				target = {group,a[i]};
				break;
			}
		}
		
		int st = target.fi*316, en = (target.fi+1)*316;
		for(int i=st; i<en; i++){
			if(a[i] == target.se) cout<<i<<" ";
		}
		cout<<endl;
	}
	
	return 0;
}

#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…