Submission #150596

#TimeUsernameProblemLanguageResultExecution timeMemory
150596Welcome to osu! (#200)King of Chairs (FXCUP4_chairs)C++17
100 / 100
113 ms7000 KiB
#include "king.h" long long SendInfo(std::vector<int> W, std::vector<int> C) { return 0; }
#include "vassal.h" #include <bits/stdc++.h> #define va first #define vb second using namespace std; typedef long long ll; typedef pair<int, int> pii; int N, cnt; int parent[101010]; vector<pii> CC; int Find(int a) { if (parent[a] == a) return a; return parent[a] = Find(parent[a]); } void Union(int a, int b) { if (Find(a) == Find(b)) return; parent[Find(b)] = Find(a); } void Init(long long B, std::vector<int> C){ N = C.size(); CC.resize(N); for (int i=0; i<N; i++) { CC[i].va = C[i]; CC[i].vb = i; } sort(CC.begin(), CC.end()); for (int i=0; i<=N; i++) parent[i] = i; return; } int Maid(int W){ ++cnt; vector<pii>::iterator lb = lower_bound(CC.begin(), CC.end(), pii(W, 0)); int idx = lb - CC.begin(); if (Find(idx) == N) return -1; int ans = CC[Find(idx)].vb; Union(Find(idx)+1, Find(idx)); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...