Submission #31324

#TimeUsernameProblemLanguageResultExecution timeMemory
31324abcdef6199Port Facility (JOI17_port_facility)C++98
22 / 100
33 ms2044 KiB
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> II; const int MAXN = 2000 + 10; const int MOD = (int) 1e9 + 7; int n, a[MAXN], b[MAXN], c[MAXN]; bool ok; void DFS(int u) { for (int v = 1; v <= n; ++v) { bool check1 = a[u] < a[v] && a[v] < b[u] && b[u] < b[v]; bool check2 = a[v] < a[u] && a[u] < b[v] && b[v] < b[u]; if (check1 || check2) { if (c[v] == -1) { c[v] = c[u] ^ 1; DFS(v); } else { if (c[v] == c[u]) ok = false; } } } } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d%d", &a[i], &b[i]); int ans = 1; ok = true; for (int i = 1; i <= n; ++i) c[i] = -1; for (int i = 1; i <= n; ++i) if (c[i] == -1) { c[i] = 0; DFS(i); ans = (ans * 2) % MOD; } if (ok == false) puts("0"); else printf("%d\n", ans); return 0; }

Compilation message (stderr)

port_facility.cpp: In function 'int main()':
port_facility.cpp:29:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
port_facility.cpp:30:58: 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", &a[i], &b[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...