제출 #986787

#제출 시각아이디문제언어결과실행 시간메모리
986787alextodoranPort Facility (JOI17_port_facility)C++17
0 / 100
1 ms348 KiB
/** _ _ __ _ _ _ _ _ _ |a ||t ||o d | |o | | __ _| | _ | __| _ | | __ |/_ | __ /__\ / _\| **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N_MAX = 2000; const int MOD = (int) 1e9 + 7; int N; int L[N_MAX + 2], R[N_MAX + 2]; vector <int> adj[N_MAX + 2]; bool seen[N_MAX + 2]; void dfs (int u) { seen[u] = true; for (int v : adj[u]) { if (seen[v] == false) { dfs(v); } } } int main () { ios_base::sync_with_stdio(false); cin.tie(0); cin >> N; for (int i = 1; i <= N; i++) { cin >> L[i] >> R[i]; } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { if (L[i] < L[j] && L[j] < R[i] && R[i] < R[j]) { adj[i].push_back(j); adj[j].push_back(i); } } } int answer = 1; for (int i = 1; i <= N; i++) { if (seen[i] == false) { dfs(i); answer = answer * 2 % MOD; } } cout << answer << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...