제출 #69128

#제출 시각아이디문제언어결과실행 시간메모리
69128InovakPort Facility (JOI17_port_facility)C++14
0 / 100
3 ms248 KiB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e6+10;
const int mod = 1e9+7;

int n;
pair <int, int> p[N];
stack <int> a, b;
ll ans = 1;

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d%d", &p[i].fr, &p[i].sc);
    }
    a.push(mod);
    b.push(mod);
    sort(p + 1, p + n + 1);
    for(int i = 1; i <= n; i++) {
        while(a.top() < p[i].fr) a.pop();
        while(b.top() < p[i].fr) b.pop();

        ll y = 2;
        bool fl = 0;
        if(a.top() < p[i].sc) y--;
        if(b.top() < p[i].sc) y--;
        if(y == 0) {puts("0");return 0;}

        if(y == 2) {
            if(a.top() < b.top()) a.push(p[i].sc);
            else b.push(p[i].sc);
        }
        if(y == 1) {
            if(a.top() < b.top()) b.push(p[i].sc);
            else a.push(p[i].sc);
        }
        ans = ans * y % mod;
    }
    cout << ans << endl;
}

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

port_facility.cpp: In function 'int main()':
port_facility.cpp:35:14: warning: unused variable 'fl' [-Wunused-variable]
         bool fl = 0;
              ^~
port_facility.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
port_facility.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &p[i].fr, &p[i].sc);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...