제출 #422959

#제출 시각아이디문제언어결과실행 시간메모리
422959schseHandcrafted 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; }

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

/usr/bin/ld: /tmp/ccof7Q7v.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