Submission #484811

#TimeUsernameProblemLanguageResultExecution timeMemory
484811MohamedFaresNebili콤보 (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#include "combo.h"
 
        using namespace std;
 
        using ll  = long long;
        using vi  = vector<int>;
 
        #define pb push_back
        #define ff first
        #define ss second
        #define lb lower_bound
        #define all(x) (x).begin() , (x).end()
 
        string guess_sequence(int N) {
            string lett = "ABXY";
            string p = ""; int first = -1;
            for(int l = 0; l < 3; l++) {
              	p = "";
                for (int i = 0; i < N; ++i) p += lett[l];
                if(press(p)) {
                    first = l;
                    break;
                }
            }
            if(first == -1) { first = 3; p[0] = lett[3]; }
            for(int i = 1; i < N; i++) {
                bool found = 0;
                for(int l = 0; l < 2; l++) {
                    if(l == first) continue;
                    p[i] = lett[l];
                    if(press(p) >= i+1) { found = 1; break; }
                }
                if(!found) {
                    if(first == 2) p[i] = lett[3];
                    else if(first == 3) p[i] = lett[2];
                  	else {
                      p[i] = lett[2];
                      if(press(p) <= i) press[i] = lett[3];
                    }
                }
            }
            return p;
        }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:41:48: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   41 |                       if(press(p) <= i) press[i] = lett[3];
      |                                                ^
combo.cpp:41:50: error: assignment of read-only location '*(press + ((sizetype)i))'
   41 |                       if(press(p) <= i) press[i] = lett[3];