Submission #20240

# Submission time Handle Problem Language Result Execution time Memory
20240 2016-07-12T03:12:09 Z baneling100 Palembang Bridges (APIO15_bridge) C++
0 / 100
0 ms 2676 KB
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#define N_MAX 100000

using namespace std;

int K, N, A[(N_MAX<<1)+1];
int M, Left[N_MAX+1], Right[N_MAX+1];
long long Ans;

int main(void) {

    int i, x, y;
    char t1, t2;

    scanf("%d %d ",&K,&N);
    for(i=1 ; i<=N ; i++) {
        scanf("%c %d %c %d ",&t1,&x,&t2,&y);
        if(t1==t2) Ans+=abs(x-y);
        else {
            Left[++M]=min(x,y);
            Right[ M]=max(x,y);
        }
    }
    if(K==1) {
        for(i=1 ; i<=M ; i++) {
            A[2*i-1]=Left[i];
            A[2*i  ]=Right[i];
        }
        sort(A+1,A+(M<<1)+1);
        for(i=1 ; i<=M ; i++)
            Ans+=(long long)abs(A[M]-Left[i])+abs(A[M]-Right[i])+1;
        printf("%d",Ans);
    }
    else {
    }

    return 0;
}

Compilation message

bridge.cpp: In function 'int main()':
bridge.cpp:34:24: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
         printf("%d",Ans);
                        ^
bridge.cpp:17: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:19:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%c %d %c %d ",&t1,&x,&t2,&y);
                                            ^
# 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 Incorrect 0 ms 2676 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 2676 KB Output isn't correct
6 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2676 KB Output isn't correct
2 Halted 0 ms 0 KB -