Submission #1314847

#TimeUsernameProblemLanguageResultExecution timeMemory
1314847exoworldgdHandcrafted Gift (IOI20_gift)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include"gift.h"
#define exoworldgd cin.tie(0)->sync_with_stdio(0),cout.tie(0)
using namespace std;
int construct(int n,int r,int[] a,int[] b,int[] x){
    string s(n,'R');
    int v[n]={};
    set<int>st;
    for(int i=0;i<n;i++)st.insert(i);
    for(int i=0;i<r;i++){
        if(x[i]==1){
            auto it=st.lower_bound(a[i]);
            if(it==st.end()||*it>a[i])it--;
            st.erase(next(it),st.upper_bound(b[i]));
        }
    }
    for(int i=0;i<r;i++){
        if(x[i]==2){
            auto it=st.lower_bound(a[i]),it2=st.lower_bound(b[i]);
            if(it==st.end()||*it>a[i])it--;
            if(it2==st.end()||*it2>b[i])it2--;
            if(it==it2)return 0;
        }
    }
    for(int i:st)v[i]^=1;
    for(int i=0,j=0;i<n;i++)j^=v[i],s[i]=j?'R','B';
    craft(s);return 1;
}

Compilation message (stderr)

gift.cpp:5:33: error: expected ',' or '...' before 'a'
    5 | int construct(int n,int r,int[] a,int[] b,int[] x){
      |                                 ^
gift.cpp: In function 'int construct(int, int, int*)':
gift.cpp:11:12: error: 'x' was not declared in this scope
   11 |         if(x[i]==1){
      |            ^
gift.cpp:12:36: error: 'a' was not declared in this scope
   12 |             auto it=st.lower_bound(a[i]);
      |                                    ^
gift.cpp:14:46: error: 'b' was not declared in this scope
   14 |             st.erase(next(it),st.upper_bound(b[i]));
      |                                              ^
gift.cpp:18:12: error: 'x' was not declared in this scope
   18 |         if(x[i]==2){
      |            ^
gift.cpp:19:36: error: 'a' was not declared in this scope
   19 |             auto it=st.lower_bound(a[i]),it2=st.lower_bound(b[i]);
      |                                    ^
gift.cpp:21:16: error: 'it2' was not declared in this scope
   21 |             if(it2==st.end()||*it2>b[i])it2--;
      |                ^~~
gift.cpp:21:36: error: 'b' was not declared in this scope
   21 |             if(it2==st.end()||*it2>b[i])it2--;
      |                                    ^
gift.cpp:22:20: error: 'it2' was not declared in this scope
   22 |             if(it==it2)return 0;
      |                    ^~~
gift.cpp:26:51: error: expected ':' before ';' token
   26 |     for(int i=0,j=0;i<n;i++)j^=v[i],s[i]=j?'R','B';
      |                                                   ^
      |                                                   :
gift.cpp:26:51: error: expected primary-expression before ';' token