Submission #466512

# Submission time Handle Problem Language Result Execution time Memory
466512 2021-08-19T14:20:34 Z vendx_greyback Colors (BOI20_colors) C++14
0 / 100
1 ms 200 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()


int32_t main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	
	int left = 1, right = n, query = 1, outcome, last_asked = 1, default_query = 2;
	cout<<"? 1"<<endl;
	cin>>outcome;
	
	while(left < right){
	    
	    int mid = left + (right-left)/2;
        last_asked = query;
        
        if(query + mid <= n)
            query = query + mid;
        
        else if(query - mid >= 1)
            query = query - mid;
        
        else
            query = default_query;
	    
	    if(query == default_query)
                default_query++;
	    
	    cout<<"? "<<query<<endl;
	    cin>>outcome;
	    
	    if(outcome)
	        right = min(right,abs(query-last_asked));
	    
	    else
	        left = max(left,abs(query-last_asked) + 1);
	    
	}
	
	cout<<"= "<<right<<'\n';

	return 0;
}

Compilation message

Colors.cpp: In function 'int32_t main()':
Colors.cpp:30:9: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   30 |         else
      |         ^~~~
Colors.cpp:33:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   33 |      if(query == default_query)
      |      ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Incorrect 1 ms 200 KB Hair color 26 was used multiple times
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Incorrect 1 ms 200 KB Hair color 26 was used multiple times
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Incorrect 1 ms 200 KB Hair color 26 was used multiple times
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Incorrect 1 ms 200 KB Hair color 26 was used multiple times
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Incorrect 1 ms 200 KB Hair color 26 was used multiple times
3 Halted 0 ms 0 KB -