답안 #132625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
132625 2019-07-19T08:53:45 Z parkky 산만한 고양이 (KOI17_cat) C++14
23 / 100
190 ms 6392 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
int N,M,p[300001],imp[300001];
struct road{
	int a,b;
}rd[600000];
int so(road x,road y){
	return x.a<y.a||(x.a==y.a&&x.b<y.b);
}
int near(int x,int y){
	return x-y==1||y-x==1||x-y==N-1||y-x==N-1;
}
long long solve3(){
	int list[2]={};
	for(int i=0;i<2*M;i++){
		if(rd[i].a>rd[i].b)continue;
		if(!near(rd[i].a,rd[i].b)){
			if(list[0]==0)list[0]=rd[i].a,list[1]=rd[i].b;
			else if(list[0]==rd[i].a||list[0]==rd[i].b)list[1]=-1;
			else if(list[1]==rd[i].a||list[1]==rd[i].b)list[0]=list[1],list[1]=-1;
			else list[0]=-1;
		}
	}
	if(list[0]==-1)return 0;
	if(list[1]==-1)return list[0];
	if(list[0])return list[0]+list[1];
	return N*(N+1)/2;
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		rd[2*i]={x,y};
		rd[2*i+1]={y,x};
	}
	sort(rd,rd+2*M,so);
	for(int i=0,j=0;i<2*M;i++){
		if(rd[i].a>j)p[j++]=i;
	}
	p[N]=2*M;
	printf("%lld",solve3());
	return 0;
}

Compilation message

cat.cpp: In function 'int main()':
cat.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&N,&M);
  ~~~~~^~~~~~~~~~~~~~
cat.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x,&y);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 190 ms 6260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 174 ms 6284 KB Output is correct
2 Correct 143 ms 6228 KB Output is correct
3 Correct 139 ms 6284 KB Output is correct
4 Correct 187 ms 6312 KB Output is correct
5 Correct 139 ms 6392 KB Output is correct
6 Correct 147 ms 6264 KB Output is correct
7 Correct 171 ms 6288 KB Output is correct
8 Correct 136 ms 6364 KB Output is correct
9 Correct 171 ms 6264 KB Output is correct
10 Correct 142 ms 6008 KB Output is correct
11 Correct 142 ms 6104 KB Output is correct
12 Correct 143 ms 6040 KB Output is correct
13 Correct 143 ms 6020 KB Output is correct
14 Correct 141 ms 6008 KB Output is correct
15 Correct 154 ms 5880 KB Output is correct
16 Correct 149 ms 6008 KB Output is correct
17 Correct 152 ms 5912 KB Output is correct
18 Correct 151 ms 5908 KB Output is correct
19 Correct 156 ms 5912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -