Submission #798969

#TimeUsernameProblemLanguageResultExecution timeMemory
798969vjudge1Port Facility (JOI17_port_facility)C++17
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e3 + 10; const int MOD = 1e9 + 7; int n; vector<int> g[N]; pair<int, int> bounds[N]; int cl[N]; bool flag = 0; void dfs(int s, int p = -1) { cl[s] = ((p == -1 || cl[p] == 2) ? 1 : 2); for(int to : g[s]) { if(!cl[to]) dfs(to, s); flag |= (cl[to] == cl[s]); } } int main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin >> n; for(int i = 0; i < n; i++) cin >> bounds[i].first >> bounds[i].second; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(bounds[i].first < bounds[j].first & bounds[j].first < bounds[i].second && bounds[i].second < bounds[j].second) g[i].push_back(j); if(bounds[i].first > bounds[j].first & bounds[j].first > bounds[i].second && bounds[i].second > bounds[j].second) g[i].push_back(j); } } int ans = 1; for(int i = 0; i < n; i++) { if(cl[i]) continue; dfs(i); ans = (ans * 2) % MOD; } if(flag) ans = 0; cout << ans; }

Compilation message (stderr)

port_facility.cpp: In function 'int main()':
port_facility.cpp:31:32: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   31 |             if(bounds[i].first < bounds[j].first & bounds[j].first < bounds[i].second && bounds[i].second < bounds[j].second)
      |                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
port_facility.cpp:33:32: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   33 |             if(bounds[i].first > bounds[j].first & bounds[j].first > bounds[i].second && bounds[i].second > bounds[j].second)
      |                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...