답안 #858917

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
858917 2023-10-09T11:51:56 Z ReLice Colors (BOI20_colors) C++14
0 / 100
1 ms 452 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
//#define endl "\n"
#define fr first
#define sc second
#define sz size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define bc back()
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e18+7;
const ll mod=1e9;
const ll N=3e5+7;;
const ld eps=1e-8;
void solve(){
    ll i,j;
    ll n;
	ll b,c=0,sum=0;
	cin>>n;
	cout<<"? "<<n/3<<endl;
	c=2;
	cin>>b;
	ll cur=n/3;
	ll l=1,r=n,d=n/2;
	while(l+1<r){
		if(cur+d<=n){
			cur+=d;
		}else{
			cur-=d;
		}
		cout<<"? "<<cur<<endl;
		cin>>b;
		c*=2;
		if(b==1){
			r=d;
			d-=n/c;
		}else{
			l=d;
			d+=n/c;
		}
	}
	cout<<"= "<<r<<endl;
}
signed main(){
    start();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll t=1;
    //cin>>t;
    while(t--) solve();
}
/*
 
 
 
 
*/

Compilation message

Colors.cpp: In function 'void solve()':
Colors.cpp:35:8: warning: unused variable 'i' [-Wunused-variable]
   35 |     ll i,j;
      |        ^
Colors.cpp:35:10: warning: unused variable 'j' [-Wunused-variable]
   35 |     ll i,j;
      |          ^
Colors.cpp:37:11: warning: unused variable 'sum' [-Wunused-variable]
   37 |  ll b,c=0,sum=0;
      |           ^~~
Colors.cpp: In function 'void fre(std::string)':
Colors.cpp:24:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Colors.cpp:24:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (3 queries)
2 Correct 0 ms 344 KB OK (6 queries)
3 Correct 0 ms 344 KB OK (4 queries)
4 Runtime error 1 ms 452 KB Execution killed with signal 8
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (3 queries)
2 Correct 0 ms 344 KB OK (6 queries)
3 Correct 0 ms 344 KB OK (4 queries)
4 Runtime error 1 ms 452 KB Execution killed with signal 8
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (3 queries)
2 Correct 0 ms 344 KB OK (6 queries)
3 Correct 0 ms 344 KB OK (4 queries)
4 Runtime error 1 ms 452 KB Execution killed with signal 8
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (3 queries)
2 Correct 0 ms 344 KB OK (6 queries)
3 Correct 0 ms 344 KB OK (4 queries)
4 Runtime error 1 ms 452 KB Execution killed with signal 8
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (3 queries)
2 Correct 0 ms 344 KB OK (6 queries)
3 Correct 0 ms 344 KB OK (4 queries)
4 Runtime error 1 ms 452 KB Execution killed with signal 8
5 Halted 0 ms 0 KB -