# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
110165 | tincamatei | Port Facility (JOI17_port_facility) | C++14 | 2 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000000;
const int MOD = 1000000007;
int box[1+2*MAX_N];
int color[1+MAX_N], last[1+MAX_N];
set<pair<int, int> > emp, c[2];
int main() {
#ifdef HOME
FILE *fin = fopen("input.in", "r");
FILE *fout = fopen("output.out", "w");
#else
FILE *fin = stdin;
FILE *fout = stdout;
#endif
int n, rez = 1;
fscanf(fin, "%d", &n);
for(int i = 1; i <= n; ++i) {
int a, b;
fscanf(fin, "%d%d", &a, &b);
box[a] = i;
box[b] = -i;
}
for(int i = 1; i <= 2 * n; ++i) {
set<pair<int, int> >::iterator it;
if(box[i] > 0) {
emp.insert(make_pair(i, box[i]));
last[box[i]] = i;
} else {
box[i] = -box[i];
it = emp.upper_bound(make_pair(last[box[i]], box[i]));
if(color[box[i]] == 0) {
rez = rez * 2 % MOD;
color[box[i]] = 1;
}
while(it != emp.end()) {
color[it->second] = 3 - color[box[i]];
c[color[it->second] - 1].insert(*it);
it = emp.erase(it);
}
it = c[color[box[i]] - 1].upper_bound(make_pair(last[box[i]], box[i]));
if(it != c[color[box[i]] - 1].end()) {
rez = 0;
}
emp.erase(make_pair(last[box[i]], box[i]));
c[color[box[i]] - 1].erase(make_pair(last[box[i]], box[i]));
}
}
fprintf(fout, "%d", rez);
fclose(fin);
fclose(fout);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |