Submission #1017739

# Submission time Handle Problem Language Result Execution time Memory
1017739 2024-07-09T09:51:34 Z aufan Palembang Bridges (APIO15_bridge) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second

using namespace std;

int32_t main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        int k, n;
        cin >> k >> n;

        int ans = 0;
        vector<int> a, b;
        for (int i = 0; i < n; i++) {
                char p, q;
                int s, t;
                cin >> p >> s >> q >> t;

                if (p == q) {
                        ans += abs(s - t);
                } else {
                        if (p == 'A') {
                                a.push_back(s);
                                b.push_back(t);
                        } else {
                                a.push_back(t);
                                b.push_back(s);
                        }
                }
        }

        if (k == 1) {
                int m = (int)a.size();
                vector<int> c;
                for (int i = 0; i < m; i++) {
                        c.push_back(a[i]);
                        c.push_back(b[i]);
                }
                sort(c.begin(), c.end());

                for (int i = 0; i < 2 * m; i++) {
                        ans += abs(c[i] - c[m]);
                }

                cout << ans << '\n';
                return 0;
        }
        
        return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -