제출 #385467

#제출 시각아이디문제언어결과실행 시간메모리
385467taulantHandcrafted Gift (IOI20_gift)C++17
컴파일 에러
0 ms0 KiB
typedef pair<int, int> pii; void craft(string& s); int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x){ vector<pii> one, two; for(int i = 0; i < r; ++i){ if(x[i] == 1) one.push_back({a[i], b[i]}); if(x[i] == 2) two.push_back({a[i], b[i]}); } sort(one.begin(), one.end()); sort(two.begin(), two.end()); string ans(n, 'R'); int f = 1; for(auto [l, r] : one){ while(f <= l){ ans[f] = ans[f-1] == 'R'? 'B' : 'R'; ++f; } while(f <= r){ ans[f] = ans[f-1]; ++f; } } // constructed a coloring, lets check if it is valid vector<int> vld(two.size(), 1); int diff = 1, idx = 0; while(diff < n){ while(diff < n && ans[diff] == ans[diff - 1]) ++diff; if(diff == n) break; while(idx < two.size() && two[idx].first < diff){ if(two[idx].second >= diff) vld[idx] = 1; ++idx; } } for(int i : vld) if(!i) return 0; craft(ans); return 1; }

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

gift.cpp:1:9: error: 'pair' does not name a type
    1 | typedef pair<int, int> pii;
      |         ^~~~
gift.cpp:3:12: error: variable or field 'craft' declared void
    3 | void craft(string& s);
      |            ^~~~~~
gift.cpp:3:12: error: 'string' was not declared in this scope
gift.cpp:3:20: error: 's' was not declared in this scope
    3 | void craft(string& s);
      |                    ^
gift.cpp:5:29: error: 'vector' has not been declared
    5 | int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x){
      |                             ^~~~~~
gift.cpp:5:35: error: expected ',' or '...' before '<' token
    5 | int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x){
      |                                   ^
gift.cpp: In function 'int construct(int, int, int)':
gift.cpp:6:2: error: 'vector' was not declared in this scope
    6 |  vector<pii> one, two;
      |  ^~~~~~
gift.cpp:6:9: error: 'pii' was not declared in this scope
    6 |  vector<pii> one, two;
      |         ^~~
gift.cpp:6:14: error: 'one' was not declared in this scope
    6 |  vector<pii> one, two;
      |              ^~~
gift.cpp:6:19: error: 'two' was not declared in this scope
    6 |  vector<pii> one, two;
      |                   ^~~
gift.cpp:8:6: error: 'x' was not declared in this scope
    8 |   if(x[i] == 1) one.push_back({a[i], b[i]});
      |      ^
gift.cpp:8:32: error: 'a' was not declared in this scope
    8 |   if(x[i] == 1) one.push_back({a[i], b[i]});
      |                                ^
gift.cpp:8:38: error: 'b' was not declared in this scope
    8 |   if(x[i] == 1) one.push_back({a[i], b[i]});
      |                                      ^
gift.cpp:9:6: error: 'x' was not declared in this scope
    9 |   if(x[i] == 2) two.push_back({a[i], b[i]});
      |      ^
gift.cpp:9:32: error: 'a' was not declared in this scope
    9 |   if(x[i] == 2) two.push_back({a[i], b[i]});
      |                                ^
gift.cpp:9:38: error: 'b' was not declared in this scope
    9 |   if(x[i] == 2) two.push_back({a[i], b[i]});
      |                                      ^
gift.cpp:11:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |  sort(one.begin(), one.end());
      |  ^~~~
      |  short
gift.cpp:13:2: error: 'string' was not declared in this scope
   13 |  string ans(n, 'R');
      |  ^~~~~~
gift.cpp:17:4: error: 'ans' was not declared in this scope
   17 |    ans[f] = ans[f-1] == 'R'? 'B' : 'R';
      |    ^~~
gift.cpp:21:4: error: 'ans' was not declared in this scope
   21 |    ans[f] = ans[f-1];
      |    ^~~
gift.cpp:26:9: error: expected primary-expression before 'int'
   26 |  vector<int> vld(two.size(), 1);
      |         ^~~
gift.cpp:29:21: error: 'ans' was not declared in this scope
   29 |   while(diff < n && ans[diff] == ans[diff - 1]) ++diff;
      |                     ^~~
gift.cpp:32:32: error: 'vld' was not declared in this scope
   32 |    if(two[idx].second >= diff) vld[idx] = 1;
      |                                ^~~
gift.cpp:36:14: error: 'vld' was not declared in this scope
   36 |  for(int i : vld) if(!i) return 0;
      |              ^~~
gift.cpp:37:8: error: 'ans' was not declared in this scope
   37 |  craft(ans);
      |        ^~~
gift.cpp:37:2: error: 'craft' was not declared in this scope
   37 |  craft(ans);
      |  ^~~~~