# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
753306 | boyliguanhan | Tug of War (BOI15_tug) | C++17 | 0 ms | 0 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>
#define doi(i) if(!adj[i].size()) {cout << "NO\n";return 0;}if(adj[i].size()<2) {q.push(i);sum+=(i>n/2?1:-1)*((*begin(adj[i])).second);}
#define shift(x) ((x)>0?bt<<(x):bt>>(-x))
using namespace std;
multiset<pair<int, int>> adj[200100];
queue<int> q;
bool del[200100];
bitset<1200000> bt;
int tot;
void dfs(int n, int N) {
if (del[n]) return;
del[n] = true;
int nxt, cost;
tie(nxt, cost) = *adj[n].begin();
if(nxt>N)
tot += cost;
else
tot-=cost;
if (!del[nxt]) {
adj[nxt].erase({n, cost});
adj[n].clear();
dfs(nxt, N);
}
}
int main() {
cin.sync_with_stdoi(false);
cin.tie(nullptr);
int n, k, sum = 0;
cin >> n >> k;
n*=2;