Submission #111340

# Submission time Handle Problem Language Result Execution time Memory
111340 2019-05-14T20:43:47 Z ppnxblstr Palembang Bridges (APIO15_bridge) C++14
22 / 100
57 ms 1648 KB
#include <bits/stdc++.h>
using namespace std;
char p[2];
char q[2];
int main(){
    int k, n;
    scanf("%d%d",&k,&n);
    vector<int> v;
    int s, t;
    long long d = 0ll;
    for(int i = 1; i <= n; i++){
        scanf("%s%d%s%d",p,&s,q,&t);
        if(p[0] == q[0]){
            d += (long long)abs(s-t);
        }else{
            v.push_back(s);
            v.push_back(t);
        }
    }
    sort(v.begin(), v.end());
    if(k == 1){
        int x = v[(v.size()-1)/2];
        for(int i : v){
            d += (long long)abs(i-x);
        }
        printf("%lld\n",d + v.size()/2);
        return 0;
    }
}
/*
1 5
B 0 A 4
B 1 B 3
A 5 B 7
B 2 A 6
B 1 A 7
 */

Compilation message

bridge.cpp: In function 'int main()':
bridge.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&k,&n);
     ~~~~~^~~~~~~~~~~~~~
bridge.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s%d%s%d",p,&s,q,&t);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 29 ms 1528 KB Output is correct
13 Correct 57 ms 1520 KB Output is correct
14 Correct 42 ms 1520 KB Output is correct
15 Correct 36 ms 1020 KB Output is correct
16 Correct 35 ms 1528 KB Output is correct
17 Correct 44 ms 1648 KB Output is correct
18 Correct 43 ms 1528 KB Output is correct
19 Correct 56 ms 1520 KB Output is correct
20 Correct 36 ms 1520 KB Output is correct
21 Correct 46 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -