이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 5;
const int inf = 1000000000;
//#define int long long
#define F first
#define S second
#define pb push_back
int n, t, a, b, lastans, k, id;
bool used[N];
vector<pair<int, int>> v;
main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> t;
int type;
while(n--){
cin >> type;
if(type == 1){
cin >> a >> b;
a = a ^ (t * lastans);
b = b ^ (t * lastans);
if(a > b) swap(a, b);
// cout << a << ' ' << b << '\n';
used[v.size()] = 1;
v.pb({a, b});
}
else if(type == 2){
cin >> id;
// cout << id - 1 << '\n';;
used[id - 1] = 0;
}
else{
cin >> a >> b >> k;
a = a ^ (t * lastans);
b = b ^ (t * lastans);
if(a > b) swap(a, b);
// cout << a << ' ' << b << '\n';
lastans = 0;
for(int i = 0; i < v.size(); ++i){
if(used[i]){
// cout << v[i].F << ' ' << v[i].S << '\n';
if(min(v[i].S, b) - max(v[i].F, a) + 1 >= k) lastans++;
}
}
// l x y r
// l x r y
// x l y r
// x l r y
cout << lastans << '\n';
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
segments.cpp:17:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
17 | main() {
| ^~~~
segments.cpp: In function 'int main()':
segments.cpp:50:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int i = 0; i < v.size(); ++i){
| ~~^~~~~~~~~~
# | 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... |