# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
72270 | 2018-08-26T06:37:59 Z | (#2175, xdoju, kazel, pps789) | 초코쿠키 기계 (FXCUP3_chocolate) | C++17 | 2996 ms | 109180 KB |
#include<bits/stdc++.h> using namespace std; namespace fio { const int BSIZE = 524288; char buffer[BSIZE]; int p = BSIZE; inline char readChar() { if(p == BSIZE) { fread(buffer, 1, BSIZE, stdin); p = 0; } return buffer[p++]; } int readInt() { char c = readChar(); while (c < '0' || c > '9') { c = readChar(); } int ret = 0; while (c >= '0' && c <= '9') { ret = ret * 10 + c - '0'; c = readChar(); } return ret; } bool isB() { char c = readChar(); while(c != 'B' && c != 'O') c = readChar(); return c == 'B'; } } bool b[300005]; set<int> c[300005], ans; void ok(int x) { for(int i : c[x]) { ans.erase(i); } } void boom(int x) { if(b[x]) return; set<int> nans; for(int i : ans) { if(c[x].count(i)) nans.insert(i); } swap(ans,nans); } vector<pair<int,bool>> query; int main() { int n = fio::readInt(), m = fio::readInt(), k = fio::readInt(); for(int i=0;i<m;i++) { int x = fio::readInt(); b[x] = true; } for(int i=0;i<k;i++) { int x = fio::readInt(), y = fio::readInt(); c[y].insert(x); c[x].insert(y); } int q = fio::readInt(); for(int i=0;i<q;i++) { int x = fio::readInt(); bool y = fio::isB(); query.emplace_back(x,y); } random_shuffle(query.begin(), query.end()); if(query.back().second) { int x = query.back().first; for(int i : c[x]) ans.insert(i); for(int i=1;i<=n;i++) if(b[i]) ans.insert(i); } else { int x = query.back().first; for(int i=1;i<=n;i++) if(!b[i]) ans.insert(i); for(int i : c[x]) ans.erase(i); } query.pop_back(); for(auto & p : query) { if(p.second) boom(p.first); else ok(p.first); } printf("%zd\n",ans.size()); for(int i : ans) printf("%d\n",i); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 14456 KB | Output is correct |
2 | Correct | 21 ms | 14536 KB | Output is correct |
3 | Correct | 26 ms | 15708 KB | Output is correct |
4 | Correct | 944 ms | 43320 KB | Output is correct |
5 | Correct | 16 ms | 43320 KB | Output is correct |
6 | Incorrect | 15 ms | 43320 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2996 ms | 109180 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 14456 KB | Output is correct |
2 | Correct | 21 ms | 14536 KB | Output is correct |
3 | Correct | 26 ms | 15708 KB | Output is correct |
4 | Correct | 944 ms | 43320 KB | Output is correct |
5 | Correct | 16 ms | 43320 KB | Output is correct |
6 | Incorrect | 15 ms | 43320 KB | Output isn't correct |