제출 #481039

#제출 시각아이디문제언어결과실행 시간메모리
481039KalashnikovPort Facility (JOI17_port_facility)C++17
22 / 100
4938 ms1048580 KiB
#include <bits/stdc++.h> #define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) #define all(a) a.begin() , a.end() #define F first #define S second using namespace std; using ll = long long; const int N = 1e6+5 , inf = 2e9 + 7; const ll INF = 1e18 , mod = 1e9+7 , P = 6547; vector<int> g[N]; int u[N]; void dfs(int v , int col = 1) { u[v] = col; for(auto to: g[v]) { if(u[to] == 0) dfs(to , 3-col); else if(u[to] == col) { cout << 0; exit(0); } } } void solve(int tc) { int n; cin >> n; vector<pair<int,int>> v; for(int i = 1; i <= n; i ++) { int a , b; cin >> a >> b; v.push_back({a , b}); } sort(all(v)); set<pair<int,int>> st; int cnt = 0; for(int i = 0; i < v.size(); i ++) { pair<int,int> to = v[i]; int last = 2*n; while(st.size() && st.begin()->F < v[i].F) { st.erase(*st.begin()); } auto it = st.begin(); while(it != st.end() && it->F < to.S) { if(v[it->S - 1].F >= last) { cout << 0; return; } last = v[it->S - 1].F; g[it->S].push_back(i+1); g[i+1].push_back(it->S); cnt ++; it ++; } st.insert({to.S , i+1}); } ll ans = 1; for(int i = 1; i <= n; i ++) { if(u[i] == 0) { dfs(i); ans *= 2; ans %= mod; } } cout << ans; } /* */ main() { ios; int tt = 1 , tc = 0; // cin >> tt; while(tt --) { solve(++tc); } return 0; }

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

port_facility.cpp: In function 'void solve(int)':
port_facility.cpp:42:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i = 0; i < v.size(); i ++) {
      |                 ~~^~~~~~~~~~
port_facility.cpp: At global scope:
port_facility.cpp:75:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   75 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...