# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1275407 | chanhchuong123 | Deda (COCI17_deda) | C++20 | 282 ms | 30628 KiB |
#include<bits/stdc++.h>
using namespace std;
const bool multiTest = false;
#define task "C"
#define fi first
#define se second
#define MASK(i) (1LL << (i))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define BIT(mask, i) ((mask) >> (i) & 1)
template<typename T1, typename T2> bool minimize(T1 &a, T2 b) {
if (a > b) a = b; else return 0; return 1;
}
template<typename T1, typename T2> bool maximize(T1 &a, T2 b) {
if (a < b) a = b; else return 0; return 1;
}
const int MAX = 200020;
int n, q;
int A[MAX];
int B[MAX];
char type[MAX];
set<int> bit[MAX];
vector<int> values;
void update(int id, int value) {
for (; id <= n; id += id & -id)
bit[id].insert(value);
}
int get(int id, int value) {
int res = MAX;
for (; id > 0; id -= id & -id) {
auto it = bit[id].lower_bound(value);
if (it != bit[id].end()) {
minimize(res, *it);
}
}
return res == MAX ? -1 : res;
}
void process(void) {
cin >> n >> q;
for (int i = 1; i <= q; ++i) {
cin >> type[i] >> A[i] >> B[i];
values.push_back(A[i]);
}
sort(all(values));
values.resize(unique(all(values)) - values.begin());
for (int i = 1; i <= q; ++i) {
A[i] = lower_bound(all(values), A[i]) - values.begin() + 1;
if (type[i] == 'M') update(A[i], B[i]);
else cout << get(A[i], B[i]) << '\n';
}
}
int main(void) {
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int nTest = 1; if (multiTest) cin >> nTest;
while (nTest--) {
process();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |