제출 #465648

#제출 시각아이디문제언어결과실행 시간메모리
465648AmirElarbiHandcrafted Gift (IOI20_gift)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define vi vector<int> #define ve vector #define ll long long #define vf vector<float> #define vll vector<pair<ll,ll>> #define ii pair<int,int> #define vvi vector<vi> #define vii vector<ii> #define gii greater<ii> #define pb push_back #define fi first #define se second #define INF 1e10 #define unsigned u #define eps 1e-18 #define eps1 1e-25 #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL); #define MAX_A 100005 #define V 450 #define re register #define maxi(a,b) ((a) > (b) ? (a) : (b)) ll MOD = 998244353; using namespace std; vi p; int findSet(int x){return (p[x] == x ? x : p[x] = findSet(x));} bool isSameSet(int x, int y){return findSet(x) == findSet(y);} void unionFind(int x, int y){ int i = findSet(x), j = findSet(y); p[i] = j; } int construct(int n, int r, int[] a, int[] b, int[] x) { p.resize(n); ve<char> s(n); for(int i = 0 ; i < n; i++){ p[i] = i; } for (int i = 0; i < n; ++i) { if(x[i] == 1){ for (int j = a[i]; j <= b[i]; ++j) { unionSet(i,j); } } } for (int i = 0; i < n; ++i) { bool p = false; if(x[i] == 2){ for (int j = a[i]; j <= b[i]; ++j) { if(!isSameSet(i,j)){ p = true; } } if(!p) return 0; } } char p = 'R'; s[i] = p; for (int i = 1; i < n; ++i) { if(isSameSet(i,i-1)){ s[i] = p; } else { if(p == 'R') p = 'B'; else p = 'R'; s[i] = p; } } craft(s); return 1; }

컴파일 시 표준 에러 (stderr) 메시지

gift.cpp:32:35: error: expected ',' or '...' before 'a'
   32 | int construct(int n, int r, int[] a, int[] b, int[] x)
      |                                   ^
gift.cpp: In function 'int construct(int, int, int*)':
gift.cpp:41:12: error: 'x' was not declared in this scope
   41 |         if(x[i] == 1){
      |            ^
gift.cpp:42:26: error: 'a' was not declared in this scope
   42 |             for (int j = a[i]; j <= b[i]; ++j)
      |                          ^
gift.cpp:42:37: error: 'b' was not declared in this scope
   42 |             for (int j = a[i]; j <= b[i]; ++j)
      |                                     ^
gift.cpp:44:17: error: 'unionSet' was not declared in this scope; did you mean 'union'?
   44 |                 unionSet(i,j);
      |                 ^~~~~~~~
      |                 union
gift.cpp:51:12: error: 'x' was not declared in this scope
   51 |         if(x[i] == 2){
      |            ^
gift.cpp:52:26: error: 'a' was not declared in this scope
   52 |             for (int j = a[i]; j <= b[i]; ++j)
      |                          ^
gift.cpp:52:37: error: 'b' was not declared in this scope
   52 |             for (int j = a[i]; j <= b[i]; ++j)
      |                                     ^
gift.cpp:63:7: error: 'i' was not declared in this scope
   63 |     s[i] = p;
      |       ^
gift.cpp:76:5: error: 'craft' was not declared in this scope
   76 |     craft(s);
      |     ^~~~~