| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 120374 | tinder | Port Facility (JOI17_port_facility) | C++14 | 6081 ms | 41212 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
const int maxn = 1e6 + 6;
int n, s[maxn], t[maxn];
vector<int> g[maxn];
int lvl[maxn], vis[maxn];
bool check(int source) {
	queue<int> Q;
	vis[source] = 1;
	Q.push(source);
	while(Q.size()) {
		int u = Q.front();
		Q.pop();
		for(int v : g[u]) {
			if(vis[v]) {
				if(lvl[v] == lvl[u]) {
					return false;
				}
			} else {
				lvl[v] = lvl[u] + 1;
				vis[v] = 1;
				Q.push(v);
			}
		}
	} return true;
}
int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	vector<ii> tmp;
	for(int i = 1; i <= n; i++) {
		int _s, _t;
		scanf("%d %d", &_s, &_t);
		tmp.emplace_back(_s, _t);
	}
	// sort(tmp.begin(), tmp.end());
	for(int i = 0; i < n; i++) {
		s[i + 1] = tmp[i].first;
		t[i + 1] = tmp[i].second;
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			if(s[i] < s[j] and s[j] < t[i] and t[i] < t[j]) {
				g[i].emplace_back(j);
				g[j].emplace_back(i);
			}
		}
	}
	const int mod = 1e9 + 7;
	int ans = 1;
	for(int i = 1; i <= n; i++) {
		if(!vis[i]) {
			if(!check(i)) {
				puts("0");
				return 0;
			} else {
				ans <<= 1;
				if(ans >= mod) {
					ans -= mod;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
