Submission #23483

# Submission time Handle Problem Language Result Execution time Memory
23483 2017-05-10T07:20:12 Z duongthoi1999 Palembang Bridges (APIO15_bridge) C++14
0 / 100
0 ms 2020 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int mod = (int) 1e9 + 7;
const ll inf = 1LL << 60;
const int maxn = (int) 1e5 + 5;
const ld eps = 1e-9;

int n, k;
vector<ii> a;
vector<int> v;
ll add, res;

int main() {
    //freopen("test.txt", "r", stdin);
    cin >> k >> n;
    rep(i, 1, n + 1) {
        char x, y;
        int l, r;
        cin >> x >> l >> y >> r;
        if(l > r) swap(l, r);
        if(x == y) add += r - l;
        else {
            a.pb(ii(l, r));
            v.pb(l);
            v.pb(r);
        }
    }
    sort(all(v));
    int p = v[SZ(v) / 2];
    cout << p << endl;
    for (auto i : a) res += 1 + abs(i.fi - p) + abs(i.se - p);
    res += add;
    cout << res << endl;
}

# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -