Submission #136657

#TimeUsernameProblemLanguageResultExecution timeMemory
136657AlliancePort Facility (JOI17_port_facility)C++14
22 / 100
107 ms16444 KiB
// In the Name of Allah #include<bits/stdc++.h> #define double long double typedef long long ll; const ll MAX_N = 2000+100; const ll MOD = 1e9+7; using namespace std; vector<int> g[MAX_N]; bool mark[MAX_N]; int cl[MAX_N]; pair<int,int> lr[MAX_N]; int n,cnt; bool intersect(int i,int j){ if (lr[i].first>lr[j].second or lr[j].first>lr[i].second) return false; if (lr[i].first<=lr[j].first and lr[j].second<=lr[i].second) return false; swap(i,j); if (lr[i].first<=lr[j].first and lr[j].second<=lr[i].second) return false; return true; } void no(){ cout << 0; exit(0); } void dfs(int v) { mark[v]++; for(auto x:g[v]){ if (mark[x]){ if (cl[x]==cl[v]) no(); } else{ cl[x] = 3-cl[v]; dfs(x); } } } int main() { cin >> n; for(int i = 1;i<=n;++i) scanf("%d%d",&lr[i].first,&lr[i].second); if (n>2000) exit(1); for(int i = 1;i<=n;++i){ for(int j = 1;j<=n;++j){ if (intersect(i,j)) g[i].push_back(j); } } for(int i = 1;i<=n;++i){ if (mark[i]) continue; cnt++; cl[i] = 1; dfs(i); } ll ans = 1; for(int i = 1;i<=cnt;++i) ans *= 2,ans %= MOD; cout << ans; return 0; }

Compilation message (stderr)

port_facility.cpp: In function 'void dfs(int)':
port_facility.cpp:33:12: warning: use of an operand of type 'bool' in 'operator++' is deprecated [-Wdeprecated]
     mark[v]++;
            ^~
port_facility.cpp: In function 'int main()':
port_facility.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&lr[i].first,&lr[i].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...