답안 #292259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
292259 2020-09-06T16:37:19 Z amiratou Hotter Colder (IOI10_hottercolder) C++14
52 / 100
3959 ms 8440 KB
#include "grader.h"
#include <bits/stdc++.h>
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;



map<pair<int,int>,int> mymap;


int HC(int N){
	mymap.clear();
	if(N==1)return 1;
	if(N==2){
		Guess(1);
		if(Guess(2)==1)return 2;
		return 1;
	}
	if(N==3){
		Guess(1);
		int k=Guess(3);
		if(!k)return 2;
		else if(k==1)return 3;
		else return 1;
	}
	int l=1,r=N,a,b,last=-1;
	while((r-l+1)>4){
		a=l+(r-l)/3,b=r-(r-l)/3;
		int med=(a+b)>>1;
		//cerr<<l<<" "<<r<<"\n";
		//cerr<<a<<" "<<b<<"\n";
		int A,B;
		if(mymap.count({a,b}))
			B=mymap[{a,b}];
		else{
			A=Guess(a),B=Guess(b),last=b;
			mymap[{a,b}]=B;
		}
		if(!B)
			return (a+b)/2;
		if(B==1)l=med+1;
		else r=med;
	}
	//cerr<<l<<" "<<r<<"\n";
	int h;
	if((r-l+1)<=3){
		if(mymap.count({l,r}))
			h=mymap[{l,r}];
		else Guess(l),h=Guess(r);
		if(!h)return l+1;
		else if(h==1)return r;
		return l;
	}
	if(mymap.count({l,r-1}))
		h=mymap[{l,r-1}];
	else Guess(l),h=Guess(r-1);
	if(!h)return l+1;
	else if(h==-1)return l;
	else if(Guess(r)==1)return r;
	return r-1;
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:32:7: warning: variable 'A' set but not used [-Wunused-but-set-variable]
   32 |   int A,B;
      |       ^
hottercolder.cpp:26:18: warning: variable 'last' set but not used [-Wunused-but-set-variable]
   26 |  int l=1,r=N,a,b,last=-1;
      |                  ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 94 ms 1400 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 3959 ms 8440 KB Output is partially correct - alpha = 0.068965517241