# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
20628 | baneling100 | Palembang Bridges (APIO15_bridge) | C++98 | 89 ms | 2676 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |