이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//-------------dilanyan------------\\
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//------------------KarginDefines--------------------\\
#define ll long long
#define pb push_back
#define all(u) (u).begin(), (u).end()
#define pqueue priority_queue
#define upper upper_bound
#define lower lower_bound
#define umap unordered_map
#define uset unordered_set
#define Kargin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Usaco freopen(".in", "r", stdin); freopen(".out", "w", stdout);
//-------------------KarginConstants------------------\\
const ll mod = 1000000007;
const ll inf = 2e9;
//-------------------KarginCode------------------------\\
const int N = 200005;
void KarginSolve() {
int n, t;
cin >> n >> t;
multiset<pair<int, pair<int, int>>> mst;
vector<pair<int, int>> in(n + 1);
int lastans = 0;
int ind = 1;
for (int i = 0;i < n;i++) {
int type; cin >> type;
if (type == 1) {
int a, b;
cin >> a >> b;
a = a ^ (t * lastans), b = b ^ (t * lastans);
if (a > b) swap(a, b);
mst.insert({ ind,{a,b} });
in[ind] = { a,b };
ind++;
}
else if (type == 2) {
int ind; cin >> ind;
mst.erase({ ind,in[ind] });
}
else {
int a, b, k;
cin >> a >> b >> k;
a = a ^ (t * lastans), b = b ^ (t * lastans);
if (a > b) swap(a, b);
int ans = 0;
for (auto it : mst) {
int l = a, r = b;
int lx = it.second.first, rx = it.second.second;
if (l > lx) swap(l, lx), swap(r, rx);
if (r < lx) continue;
if (lx >= l && rx <= r) ans += (rx - lx + 1 >= k);
else if (l >= lx && r <= rx) ans += (r - l + 1 >= k);
else ans += (r - lx + 1 >= k);
}
cout << ans << '\n';
lastans = ans;
}
}
}
int main() {
//Usaco
Kargin;
int test = 1;
//cin >> test;
while (test--) {
KarginSolve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
segments.cpp:1:1: warning: multi-line comment [-Wcomment]
1 | //-------------dilanyan------------\\
| ^
segments.cpp:8:1: warning: multi-line comment [-Wcomment]
8 | //------------------KarginDefines--------------------\\
| ^
segments.cpp:22:1: warning: multi-line comment [-Wcomment]
22 | //-------------------KarginConstants------------------\\
| ^
segments.cpp:27:1: warning: multi-line comment [-Wcomment]
27 | //-------------------KarginCode------------------------\\
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |