# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
925332 | Karoot | Collider (IZhO11_collider) | C++17 | 896 ms | 95572 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/extc++.h>
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
ll linf = 1e15+1;
inline void scoobydoobydoo(){
ios::sync_with_stdio(false);
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
using namespace __gnu_pbds;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;
int main(){
scoobydoobydoo();
int n, m; cin >> n >> m;
Tree<pair<long double, int> > s; // %3 0 -> x, 1 -> y, 2 -> z
int counter = 1;
s.insert({0, -1});
for (long double i = 1; i <= n; i++){
char c; cin >> c;
if (c == 'x')s.insert({i*(1e11), 0});
else if (c == 'y')s.insert({i*(1e11), 1});
else s.insert({i*(1e11), 2});
}
s.insert({1e25, -1});
vector<char> ans;
for (int i = 0; i < m; i++){
char c; cin >> c;
if (c == 'a'){
int x, y; cin >> x >> y;
auto it = s.find_by_order(x);
int sec = (*it).second;
s.erase(it);
auto itr = s.find_by_order(y-1);
auto itr2 = s.find_by_order(y);
long double nVal = ((*itr).first + (*itr2).first)/2.0;
s.insert({nVal, sec});
} else {
int x; cin >> x;
auto it = s.find_by_order(x);
int sec = (*it).second;
if (sec == 0)ans.push_back('x');
else if (sec == 1)ans.push_back('y');
else ans.push_back('z');
}
//for (auto& e : s)cout << "(" << e.first << "," << e.second << "), ";
//cout << endl;
}
for (char c : ans)cout << c << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |