# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
989291 | aykhn | Palembang Bridges (APIO15_bridge) | C++17 | 0 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3F3F3F3F3F3F3F3F
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int k, n, S = 0;
cin >> k >> n;
vector<int> id, L, pL, sL, R, pR, sR;
for (int i = 0; i < n; i++)
{
char a, b;
int l, r;
cin >> a >> l >> b >> r;
if (l > r) swap(l, r);
S += r - l;
if (a != b) id.push_back(l), id.push_back(r), L.push_back(r), R.push_back(l);
}
sort(id.begin(), id.end()), sort(L.begin(), L.end()), sort(R.begin(), R.end());
id.resize(unique(id.begin(), id.end()) - id.begin());
pL = sL = L, pR = sR = R;
for (int i = 1; i < pL.size(); i++) pL[i] += pL[i - 1];
for (int i = 1; i < pR.size(); i++) pR[i] += pR[i - 1];
for (int i = (int)sL.size() - 2; i >= 0; i--) sL[i] += sL[i + 1];
for (int i = (int)sR.size() - 2; i >= 0; i--) sR[i] += sR[i + 1];
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |