제출 #197485

#제출 시각아이디문제언어결과실행 시간메모리
197485dennisstarPort Facility (JOI17_port_facility)C++17
100 / 100
2341 ms79864 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define ryan bear
#define sq(X) ((X)*(X))
#define eb emplace_back
#define all(V) (V).begin(), (V).end()
#define unq(V) (V).erase(unique(all(V)), (V).end())
using namespace std;
typedef long long ll;
typedef vector<ll> vlm;
typedef vector<int> vim;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const ll MOD=1e9+7;
int N; ll ans=1; vector<pii> V; set<pii> S;

vim par;
int get(int x) { return par[x]==-1?x:par[x]=get(par[x]); }
void Union(int x, int y) { x=get(x), y=get(y); if (x!=y) par[y]=x; }

int main() {
	scanf("%d", &N); V.resize(N); par.resize(2*N); fill(all(par), -1);
	for (auto &i:V) scanf("%d %d", &i.fi, &i.se);
	sort(all(V));
	for (int i=0; i<N; i++) {
		auto s=S.lower_bound(pii(V[i].fi, 0)), e=S.upper_bound(pii(V[i].se, (1<<30)));
		if (e!=S.begin()) for (; s!=e; ++s) {
			Union(i, s->se+N);
			Union(i+N, s->se);
			if (get(s->se)==get(prev(e)->se)) break;
		}
		S.emplace(V[i].se, i);
	}
	for (int i=0; i<N; i++) if (get(i)==get(i+N)) { puts("0"); return 0; }
	for (int i=0; i<N; i++) if (get(i)==i) ans=ans*2%MOD;
	printf("%lld\n", ans);
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

port_facility.cpp: In function 'int main()':
port_facility.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N); V.resize(N); par.resize(2*N); fill(all(par), -1);
  ~~~~~^~~~~~~~~~
port_facility.cpp:27:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (auto &i:V) scanf("%d %d", &i.fi, &i.se);
                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...