제출 #20628

#제출 시각아이디문제언어결과실행 시간메모리
20628baneling100Palembang Bridges (APIO15_bridge)C++98
22 / 100
89 ms2676 KiB
#include <stdio.h> #include <stdlib.h> #include <algorithm> using namespace std; int K, N, Left[100001], Right[100001], P[200001]; long long Ans; int main(void) { int i, temp=0, s, t; char p, q; scanf("%d %d ",&K,&N); for(i=1 ; i<=N ; i++) { scanf("%c %d %c %d ",&p,&s,&q,&t); if(p==q) Ans+=abs(s-t); else { temp++; Left[temp]=min(s,t); Right[temp]=max(s,t); } } N=temp; for(i=1 ; i<=N ; i++) { P[2*i-1]=Left[i]; P[2*i ]=Right[i]; } sort(P+1,P+2*N+1); if(K==1) { for(i=1 ; i<=N ; i++) { if(P[N]<Left[i]) Ans+=Left[i]+Right[i]-2*P[N]+1; else if(P[N]>Right[i]) Ans+=2*P[N]-Left[i]-Right[i]+1; else Ans+=Right[i]-Left[i]+1; } printf("%lld",Ans); } else { } return 0; }

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

bridge.cpp: In function 'int main()':
bridge.cpp:15:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d ",&K,&N);
                          ^
bridge.cpp:17:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%c %d %c %d ",&p,&s,&q,&t);
                                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...