Submission #434178

#TimeUsernameProblemLanguageResultExecution timeMemory
434178vanicHandcrafted Gift (IOI20_gift)C++14
Compilation error
0 ms0 KiB
#include "gift.h" #include <iostream> #include <cmath> #include <algorithm> #include <vector> using namespace std; const int maxn=5e5+5; const string s="RB"; int pref[maxn]; int poz[maxn]; int neg[maxn]; string sol; int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x) { for(int i=0; i<r; i++){ if(x[i]==1){ poz[a[i]]++; neg[b[i]+1]++; } } int sw=0; bool p=0; for(int i=0; i<n; i++){ sw-=neg[i]; if(!sw){ p^=1; } sw+=poz[i]; pref[i+1]=pref[i]+p; sol.push_back(s[p]); } for(int i=0; i<r; i++){ if(x[i]==2 && (pref[b[i]+1]-pref[a[i]]==0 || pref[b[i]+1]-pref[a[i]]==b[i]-a[i]+1)){ return 0; } } } craft(sol); return 1; }

Compilation message (stderr)

gift.cpp:42:7: error: expected constructor, destructor, or type conversion before '(' token
   42 |  craft(sol);
      |       ^
gift.cpp:43:2: error: expected unqualified-id before 'return'
   43 |  return 1;
      |  ^~~~~~
gift.cpp:44:1: error: expected declaration before '}' token
   44 | }
      | ^
gift.cpp: In function 'int construct(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
gift.cpp:41:2: warning: control reaches end of non-void function [-Wreturn-type]
   41 |  }
      |  ^