제출 #62661

#제출 시각아이디문제언어결과실행 시간메모리
62661gusfringPort Facility (JOI17_port_facility)C++14
22 / 100
41 ms1280 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;
}

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

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