Submission #950484

#TimeUsernameProblemLanguageResultExecution timeMemory
950484LucaLucaMPort Facility (JOI17_port_facility)C++17
0 / 100
1 ms2392 KiB
#include <iostream> #include <cassert> #include <algorithm> #include <vector> #include <cstring> #include <set> typedef long long ll; const int NMAX = 1e6; const int mod = 1e9 + 7; int p[2 * NMAX + 1]; int add[2 * NMAX + 1]; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(0); int n; std::cin >> n; for (int i = 1; i <= n; i++) { int a, b; std::cin >> a >> b; p[a] = b; } /** 12345678 XYXZYTTZ cum verific daca pot in 1 mod? cum verifica daca pot in 2 moduri? [ ] [ ] [ ] cum verific sa nu am i < j < k si a[k] < b[i] < b[j] < b[k]? **/ int where = 2; int a[n], b[n]; for (int i = 1, k = 0; i <= 2 * n; i++) { if (!p[i]) { continue; } a[k] = i; b[k] = p[i]; k++; } for (int i = 0; i + 2 < n; i++) { for (int j = i + 1; j + 1 < n; j++) { for (int k = j + 1; k < n; k++) { if (a[k] < b[i] && b[i] < b[j] && b[j] < b[k]) { std::cout << 0; return 0; } } } } std::set<int> st; int answer = 1; for (int i = 1; i <= 2 * n; i++) { if (!p[i]) { continue; } while (!st.empty() && *st.begin() < i) { st.erase(st.begin()); } if (st.empty() || *st.begin() > p[i]) { answer = answer * 2 % mod; } st.insert(p[i]); } std::cout << answer; return 0; }

Compilation message (stderr)

port_facility.cpp: In function 'int main()':
port_facility.cpp:46:7: warning: unused variable 'where' [-Wunused-variable]
   46 |   int where = 2;
      |       ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...