Submission #20628

# Submission time Handle Problem Language Result Execution time Memory
20628 2017-02-13T00:03:45 Z baneling100 Palembang Bridges (APIO15_bridge) C++
22 / 100
89 ms 2676 KB
#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;
}

Compilation message

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 time Memory Grader output
1 Correct 0 ms 2676 KB Output is correct
2 Correct 0 ms 2676 KB Output is correct
3 Correct 0 ms 2676 KB Output is correct
4 Correct 0 ms 2676 KB Output is correct
5 Correct 0 ms 2676 KB Output is correct
6 Correct 0 ms 2676 KB Output is correct
7 Correct 0 ms 2676 KB Output is correct
8 Correct 0 ms 2676 KB Output is correct
9 Correct 0 ms 2676 KB Output is correct
10 Correct 0 ms 2676 KB Output is correct
11 Correct 0 ms 2676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2676 KB Output is correct
2 Correct 0 ms 2676 KB Output is correct
3 Correct 0 ms 2676 KB Output is correct
4 Correct 0 ms 2676 KB Output is correct
5 Correct 0 ms 2676 KB Output is correct
6 Correct 0 ms 2676 KB Output is correct
7 Correct 0 ms 2676 KB Output is correct
8 Correct 0 ms 2676 KB Output is correct
9 Correct 0 ms 2676 KB Output is correct
10 Correct 0 ms 2676 KB Output is correct
11 Correct 0 ms 2676 KB Output is correct
12 Correct 33 ms 2676 KB Output is correct
13 Correct 89 ms 2676 KB Output is correct
14 Correct 46 ms 2676 KB Output is correct
15 Correct 46 ms 2676 KB Output is correct
16 Correct 49 ms 2676 KB Output is correct
17 Correct 49 ms 2676 KB Output is correct
18 Correct 46 ms 2676 KB Output is correct
19 Correct 69 ms 2676 KB Output is correct
20 Correct 43 ms 2676 KB Output is correct
21 Correct 63 ms 2676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2676 KB Output isn't correct
2 Halted 0 ms 0 KB -