# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
876703 | VahanAbraham | Weighting stones (IZhO11_stones) | C++14 | 1 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.
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <cmath>
#include <vector>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pb push_back
#define US freopen("milkvisits.in", "r", stdin); freopen("milkvisits.out", "w", stdout);
ll gcd(ll a, ll b)
{
if (a == 0 || b == 0) {
return max(a, b);
}
if (a <= b) {
return gcd(a, b % a);
}
else {
return gcd(a % b, b);
}
}
ll lcm(ll a, ll b) {
return (a / gcd(a, b)) * b;
}
const int N = 300005;
const ll oo = 1000000000000000, MOD = 1000000007;
int sz = 1,t[3 * N][3];
void init(int n) {
while (sz < n) {
sz *= 2;
}
}
int get(int l, int r, int i, int lx, int rx, int x) {
if (lx - rx == 0) {
t[x][i] = 0;
return lx;
}
int m = (lx + rx) / 2, y = 1;
if (t[2 * x + 1][i] > 0) {
y = get(l, r, i, m + 1, rx, 2 * x + 1);
}
else {
y= get(l, r, i, lx, m, 2 * x);
}
t[x][i] = t[2 * x][i] + t[2 * x + 1][i];
return y;
}
void seet(int ind, int i, int l, int r, int x) {
if (r == l) {
t[x][i] = 1;
return;
}
int m = (l + r) / 2;
if (ind <= m) {
seet(ind, i, l, m, 2 * x);
}
else {
seet(ind, i, m + 1, r, 2 * x + 1);
}
t[x][i] = t[2 * x][i] + t[2 * x + 1][i];
}
void solve() {
int q;
cin >> q;
int y = 0, mx = 0;
init(q);
while (q--) {
int r, s;
cin >> r >> s;
if (r > mx) {
mx = r, y = s;
}
if (s == 2) {
int x = get(1, r, 1, 1, sz, 1);
seet(r,2, 1, sz, 1);
}
else {
int x=get(1, r, 2, 1, sz, 1);
seet(r, 1, 1, sz, 1);
}
if (y == 2) {
if (t[1][1] > 0) {
cout << "?" << endl;
}
else {
cout << "<" << endl;
}
}
else {
if (t[1][2] > 0) {
cout << "?" << endl;
}
else {
cout << ">" << endl;
}
}
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//US
int tt = 1;
//cin >> tt;
while (tt--) {
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |