Submission #673276

# Submission time Handle Problem Language Result Execution time Memory
673276 2022-12-20T05:18:32 Z hariaakas646 Colors (BOI20_colors) C++17
0 / 100
1 ms 208 KB
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCLLU(t) scanf("%llu",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define for_range(i, j) FOR(i, 0, j, 1)
#define all(cont) cont.begin(), cont.end()
#define MP make_pair
#define PB push_back
 
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
 
int main()
{
    uint64 n;
    SCLLU(n);
    uint64 l = 0; uint64 r = n;
    uint64 pred = n / 2;
    cout << "? " << pred << endl;
    int rep;
    SCD(rep);
    pred = 1;
    while(l != r) {
        if(pred > n) {
            pred = 1;
            cout << "? " << pred << endl;
            SCD(rep);
            pred = pred + (r + l)/2;
            continue;
        }
        cout << "? " << pred << endl;
        SCD(rep);
        if(rep == 0) {
            l = (r+l)/2 + 1;
        }
        else {
            r = (r+l)/2;
        }
        if(pred > (r + l)/2) pred = pred - (r + l)/2;
        else pred = pred + (r + l)/2;
        
        
    }
    cout << "= " << l << endl;
    
    
    
    
    return 0;
}

Compilation message

Colors.cpp: In function 'int main()':
Colors.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | #define SCLLU(t) scanf("%llu",&t)
      |                  ~~~~~^~~~~~~~~~~
Colors.cpp:37:5: note: in expansion of macro 'SCLLU'
   37 |     SCLLU(n);
      |     ^~~~~
Colors.cpp:6:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define SCD(t) scanf("%d",&t)
      |                ~~~~~^~~~~~~~~
Colors.cpp:42:5: note: in expansion of macro 'SCD'
   42 |     SCD(rep);
      |     ^~~
Colors.cpp:6:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define SCD(t) scanf("%d",&t)
      |                ~~~~~^~~~~~~~~
Colors.cpp:48:13: note: in expansion of macro 'SCD'
   48 |             SCD(rep);
      |             ^~~
Colors.cpp:6:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define SCD(t) scanf("%d",&t)
      |                ~~~~~^~~~~~~~~
Colors.cpp:53:9: note: in expansion of macro 'SCD'
   53 |         SCD(rep);
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB OK (4 queries)
2 Incorrect 1 ms 208 KB Hair color 1 was used multiple times
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB OK (4 queries)
2 Incorrect 1 ms 208 KB Hair color 1 was used multiple times
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB OK (4 queries)
2 Incorrect 1 ms 208 KB Hair color 1 was used multiple times
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB OK (4 queries)
2 Incorrect 1 ms 208 KB Hair color 1 was used multiple times
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB OK (4 queries)
2 Incorrect 1 ms 208 KB Hair color 1 was used multiple times
3 Halted 0 ms 0 KB -