제출 #422958

#제출 시각아이디문제언어결과실행 시간메모리
422958schseHandcrafted Gift (IOI20_gift)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; void craft(string s) { cout<<s; } struct requirement { int l, r, x; bool operator<(requirement a) const { return x == a.x ? l < a.l : x < a.x; } }; int construct(int n, int r, int *a, int *b, int *x) { std::vector<requirement> rec; rec.resize(r); bool allsame = true; bool alldiff = true; for (int i = 0; i < r; i++) { rec[i].l = a[i]; rec[i].r = b[i]; rec[i].x = x[i]; if (x[i] == 2) allsame = false; else alldiff = false; } string str; str.resize(n); if (allsame) { fill(str.begin(), str.end(), 'R'); craft(str); return 1; } if (alldiff) { for (int i = 0; i < n; i++) str[i] = i % 2 ? 'B' : 'R'; craft(str); return 1; } fill(str.begin(), str.end(), '0'); sort(rec.begin(), rec.end()); queue<requirement> scol, mcol; for (auto i : rec) { if (i.x == 1) scol.push(i); else mcol.push(i); } for (int col=0, i = 0; i < n; i++) { if(str[i]=='0') { col++,col%=2; str[i]=col?'R':'B'; } if(!scol.empty() && scol.front().l==i) { fill(&str[scol.front().l],&str[scol.front().r+1],str[scol.front().l]); scol.pop(); } } while (!mcol.empty()) { bool r=false,b=false; for (int i = mcol.front().l; i < mcol.front().r+1; i++){ if(str[i]=='R') r=true; else b=true; } if(!r||!b) return 0; mcol.pop(); } craft(str); return 1; } int main() { int n = 4, r = 2, a[2] = {0, 2}; int b[2] = {2, 3}; int x[2] = {2, 1}; construct(n, r, a, b, x); }

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

/usr/bin/ld: /tmp/ccW6lCXd.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc0Yr4vb.o:gift.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccW6lCXd.o: in function `main':
grader.cpp:(.text.startup+0x272): undefined reference to `construct(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status