# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84005 | ekrem | Port Facility (JOI17_port_facility) | C++98 | 2 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;
int n, fen1[N], fen2[N];
pair < int , int > x[N];
long long ans = 1;
void up1(int x, int y){
for(; x <= n+n; x += x&-x)
fen1[x] += y;}
int qu1(int x){
int top = 0;
for(; x > 0; x -= x&-x)
top += fen1[x];
return top;}
void up2(int x, int y){
for(; x <= n+n; x += x&-x)
fen2[x] += y;}
int qu2(int x){
int top = 0;
for(; x > 0; x -= x&-x)
top += fen2[x];
return top;}
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
scanf("%d",&n);
for(int i = 1; i <= n; i++)
scanf("%d %d",&x[i].st ,&x[i].nd);
sort(x + 1, x + n + 1);
for(int i = 1; i <= n; i++){
int q1 = qu1(x[i].nd) - qu1(x[i].st);
int q2 = qu2(x[i].nd) - qu2(x[i].st);
if(q1 and q2){
ans = 0;
break;
}
if(!q1 and !q2)
ans = ans*2%mod;
if(!q1){
up1(x[i].nd, 1);
} else
up2(x[i].nd, 1);
}
printf("%lld\n", ans);
return 0;
}
Compilation message (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... |