Submission #23672

#TimeUsernameProblemLanguageResultExecution timeMemory
23672rubabredwanPort Facility (JOI17_port_facility)C++14
22 / 100
103 ms19568 KiB
/* Bismillahir Rahmanir Rahim */ #include <bits/stdc++.h> using namespace std; const int N = 2005; int n; int st[N], en[N]; int vis[N], flag, col[N]; vector<int>g[N]; void dfs(int at){ vis[at] = 1; for(auto u : g[at]){ if(!vis[u]){ col[u] = col[at] ^ 1; dfs(u); } if(col[u] == col[at]) flag = 1; } } int main(){ scanf("%d", &n); for(int i=1;i<=n;i++) scanf("%d %d", &st[i], &en[i]); for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(st[j] < st[i] && st[i] < en[j] && en[i] > en[j]){ g[i].push_back(j); g[j].push_back(i); } } } int comp = 0; for(int i=1;i<=n;i++){ if(vis[i]) continue; col[i] = 0; dfs(i); ++comp; } if(flag) cout << 0 << endl; else{ long long mod = 1e9 + 7; long long ret = 1LL; for(int i=1;i<=comp;i++){ ret *= 2LL; ret %= mod; } cout << ret << endl; } return 0; }

Compilation message (stderr)

port_facility.cpp: In function 'int main()':
port_facility.cpp:26:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
port_facility.cpp:27:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++) scanf("%d %d", &st[i], &en[i]);
                                                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...