Submission #404551

# Submission time Handle Problem Language Result Execution time Memory
404551 2021-05-14T15:28:57 Z danielcm585 Palembang Bridges (APIO15_bridge) C++14
22 / 100
48 ms 3524 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> ii;
 
int n, k, s, t; 
char p, q; 

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> k >> n;
    ll ans = 0;
    vector<int> v;
    for (int i = 1; i <= n; i++) {
        cin >> p >> s >> q >> t;
        if (p == q) ans += abs(s-t);
        else {
            v.push_back(s);
            v.push_back(t);
        }
    }
    sort(v.begin(),v.end());
    int mid = v.size()/2;
    for (int i = 0; i < v.size(); i++) {
        ans += abs(v[mid-1]-v[i]);
    }
    ans += mid;
    cout << ans << '\n';
    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:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 280 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 216 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 2 ms 320 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 25 ms 2124 KB Output is correct
13 Correct 48 ms 3524 KB Output is correct
14 Correct 35 ms 2512 KB Output is correct
15 Correct 28 ms 2244 KB Output is correct
16 Correct 34 ms 2780 KB Output is correct
17 Correct 35 ms 3496 KB Output is correct
18 Correct 44 ms 3060 KB Output is correct
19 Correct 46 ms 3448 KB Output is correct
20 Correct 37 ms 3052 KB Output is correct
21 Correct 46 ms 3192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -