Submission #466753

#TimeUsernameProblemLanguageResultExecution timeMemory
466753M4mouHandcrafted Gift (IOI20_gift)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "gift.h" using namespace std; vector<int>parent; void init(int n) { parent.resize(n); for(int l=0;l<n;l++) parent[l]=l; } int findset(int n) { return (parent[n]==n)?n:(parent[n]=findset(parent[n])); } bool sameSet(int a, int b) { return findset(a)==findset(b); } void unionSet(int a, int b) { if(sameSet(a, b)) return; a=findset(a); b=findset(b); parent[a]=b; } int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) { init(n+1); for(int i = 0: i < r; i++){ if(x[i] == 2) continue; int j = a[i]; while(findset(j) != findset(b[i])){ unionSet(j,b[i]); j++; } } for(int i=0;i<r;i++){ if(x[i]==1){ continue; } if(findset(a[i])==findset(b[i])){ return 0; } } string s ="R"; for(int i=1;i<n;i++) { if(findset(i) != findset(i-1)) if(s.back() == "R")s += "B"; else s+= "R"; else s+= s.back(); } craft(s); return 1; }

Compilation message (stderr)

gift.cpp: In function 'int construct(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
gift.cpp:17:15: error: initializer in range-based 'for' loop
   17 |     for(int i = 0: i < r; i++){
      |               ^
gift.cpp:17:25: error: expected ')' before ';' token
   17 |     for(int i = 0: i < r; i++){
      |        ~                ^
      |                         )
gift.cpp:17:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   17 |     for(int i = 0: i < r; i++){
      |     ^~~
gift.cpp:17:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   17 |     for(int i = 0: i < r; i++){
      |                           ^
gift.cpp:17:27: error: 'i' was not declared in this scope
gift.cpp:44:21: warning: comparison with string literal results in unspecified behavior [-Waddress]
   44 |         if(s.back() == "R")s += "B";
      |            ~~~~~~~~~^~~~~~
gift.cpp:44:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]