이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define debug(a) //cout << #a << " = " << a << endl
#define debugsl(a) //cout << #a << " = " << a << ", "
#define MAX 1000000
#define mod 1000000007
#define v first
#define id second.first
#define tipo second.second
lli offset,n,res,a;
lli pari[MAX+2];
vector< pair<lli, pair<lli,lli> > > eventos;
lli inicios[MAX + 2], fines[MAX + 2];
set<pair<lli, lli> > cceros, cunos, cdos;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
rep(i,1,n){
cin >> inicios[i] >> fines[i];
eventos.push_back({inicios[i],{i,1} });
eventos.push_back({fines[i],{i,0} });
}
sort(eventos.begin(), eventos.end());
res = 1;
for (auto act : eventos) {
debugsl(act.tipo);
debugsl(act.v);
debug(act.id);
if (act.tipo == 1){
cceros.insert({act.v, act.id});
}
else {
debug(pari[act.id]);
if (pari[act.id] == 0) {
res *= 2;
res %= mod;
pari[act.id] = 1;
}
auto it = cceros.upper_bound({inicios[act.id], n + 1});
lli nuevapar = pari[act.id] ^ 3;
while (it != cceros.end()){
debugsl(nuevapar);
debug((*it).second);
if (pari[(*it).second] == 0) pari[(*it).second] = nuevapar;
else if (pari[(*it).second] != nuevapar){
res = 0;
break;
}
it++;
}
cceros.erase({inicios[act.id], act.id});
}
}
cout << res;
}
# | 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... |