# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
859923 | aykhn | 입자 가속기 (IZhO11_collider) | C++14 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
// author : aykhn
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define pb push_back
#define ins insert
#define mpr make_pair
#define all(v) v.begin(), v.end()
#define bpc __builtin_popcount
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define int ll
#define infll 0x3F3F3F3F3F3F3F3F
#define inf 0x3F3F3F3F
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
ordered_set<pair<pii, char>> os;
int n, q;
cin >> n >> q;
string s;
cin >> s;
s = "." + s;
for (int i = 1; i <= n; i++) os.ins(mpr(mpr(i, 0), s[i]));
for (int i = 1; i <= q; i++)
{
char ch;
cin >> ch;
if (ch == 'a')
{
int l, r;
cin >> l >> r;
auto it = os.find_by_order(l - 1);
auto it1 = os.find_by_order(r - 1);
pair<pii, char> p = *it, p1 = *it1;
os.erase(it);
p.fi = p1.fi;
p.fi.se = i;
os.ins(p);
}
else
{
int ind;
cin >> ind;
cout << (*os.find_by_order(ind - 1)).se << '\n';
}
for (pair<pii, char> p : os)
{
cout << p.se;
}
cout << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |