Submission #79449

#TimeUsernameProblemLanguageResultExecution timeMemory
79449PlurmPort Facility (JOI17_port_facility)C++11
22 / 100
59 ms17592 KiB
#include <bits/stdc++.h> using namespace std; vector<int> g[2048]; int col[2048]; bool dfs(int u,int p = -1,int c = 1){ col[u] = c; c = c % 2 + 1; for(int v : g[u]){ if(v == p) continue; if(col[v] && col[v] != c) return false; if(col[v]) continue; if(!dfs(v,u,c)) return false; } return true; } int main(){ int n; scanf("%d",&n); vector<pair<int,int> > pts; int a,b; for(int i = 0; i < n; i++){ scanf("%d%d",&a,&b); pts.emplace_back(a,b); } for(int i = 0; i < n; i++){ for(int j = i+1; j < n; j++){ if(pts[j].first < pts[i].first && pts[i].first < pts[j].second && pts[j].second < pts[i].second){ g[j].push_back(i); g[i].push_back(j); }else if(pts[i].first < pts[j].first && pts[j].first < pts[i].second && pts[i].second < pts[j].second){ g[j].push_back(i); g[i].push_back(j); } } } int c = 0; for(int i = 0; i < n; i++){ if(!col[i]){ if(dfs(i)) c++; else{ printf("0\n"); return 0; } } } int ans = 1; for(int i = 0; i < c; i++){ ans *= 2; ans %= 1000000007; } printf("%d\n",ans); return 0; }

Compilation message (stderr)

port_facility.cpp: In function 'int main()':
port_facility.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
port_facility.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&a,&b);
   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...