Submission #27894

# Submission time Handle Problem Language Result Execution time Memory
27894 2017-07-14T11:23:47 Z suhgyuho_william Port Facility (JOI17_port_facility) C++14
0 / 100
0 ms 14716 KB
#include <bits/stdc++.h>

#define lld long long
#define pii pair<int,int>
#define pll pair<lld,lld>
#define pb push_back
#define next nextt
#define left leftt
#define right rightt
#define Inf 1000000000
#define Linf 1000000000000000000LL
#define Mod 1000000007LL

using namespace std;

int N; lld ans,inv;
struct data{
	int x,y;
	bool operator < (const data &cmp) const{
		if(x != cmp.x) return x < cmp.x;
		return y < cmp.y;
	}
}a[1000002];
int d[1000002];
bool check[1000002];

void impossible(){puts("0");exit(0);}
void dfs(int x,int value){
	if(check[x]){
		if(d[x] != value) impossible();
		return;
	}
	d[x] = value;
	check[x] = true;
	for(int i=x+1; i<=N; i++){
		if(a[x].x < a[i].x && a[i].x < a[x].y && a[x].y < a[i].y){
			dfs(i,3-d[x]);
		}
	}
	return;
	for(int i=1; i<x; i++){
		if(a[i].x < a[x].x && a[x].x < a[i].y && a[i].y < a[x].y){
			dfs(i,3-d[x]);
		}
	}
}

int main(){
	scanf("%d",&N); ans = 1;
	for(int i=1; i<=N; i++){
		scanf("%d %d",&a[i].x,&a[i].y);
	}
	sort(a+1,a+N+1);
	for(int i=1; i<=N; i++){
		if(check[i]) continue;
		dfs(i,1);
		ans *= 2; ans %= Mod;
	}
	printf("%lld\n",ans);

	return 0;
}

Compilation message

port_facility.cpp: In function 'int main()':
port_facility.cpp:49:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N); ans = 1;
                ^
port_facility.cpp:51:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&a[i].x,&a[i].y);
                                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 14716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 14716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 14716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 14716 KB Output isn't correct
2 Halted 0 ms 0 KB -