제출 #482701

#제출 시각아이디문제언어결과실행 시간메모리
482701malarHandcrafted Gift (IOI20_gift)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "gift.h" using namespace std; #include <algorithm> #include <vector> #include <cassert> #include <cstdio> #include <string> vector<int>parent; int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) { parent.resize(n); for(int l=0;l<n;l++) parent[l]=l; for(int i = 0; i < r; i++){ if(x[i] == 2) continue; for (int e = b[i] + 1; e < n; e++) parent[e] -= parent[b[i]] - parent[a[i]]; for (int e = a[i] + 1; e < b[i] + 1; e++) parent[e] = parent[a[i]]; } for(int i=0; i < r; i++) { if(x[i] == 1) continue; if(a[i] == b[i]) return 0; if (parent[b[i]] - parent[a[i]] < 1) return 0; } } string s ="R"; for(int i=1;i<n;i++) { if(parent[i] != parent[i-1]) if(s.back() == 'R')s += "B"; else s+= "R"; else s+= s.back(); } craft(s); return 1; }

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

gift.cpp:37:1: error: expected unqualified-id before 'for'
   37 | for(int i=1;i<n;i++)
      | ^~~
gift.cpp:37:13: error: 'i' does not name a type
   37 | for(int i=1;i<n;i++)
      |             ^
gift.cpp:37:17: error: 'i' does not name a type
   37 | for(int i=1;i<n;i++)
      |                 ^
gift.cpp:44:10: error: expected constructor, destructor, or type conversion before '(' token
   44 |     craft(s);
      |          ^
gift.cpp:45:5: error: expected unqualified-id before 'return'
   45 |     return 1;
      |     ^~~~~~
gift.cpp:46:1: error: expected declaration before '}' token
   46 | }
      | ^
gift.cpp: In function 'int construct(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
gift.cpp:32:5: warning: control reaches end of non-void function [-Wreturn-type]
   32 |     }
      |     ^