Submission #1110289

#TimeUsernameProblemLanguageResultExecution timeMemory
1110289KasymKSegments (IZhO18_segments)C++17
7 / 100
5077 ms7304 KiB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int f(int a, int b, int c, int d){
	if(a>c)
		swap(a,c), swap(b,d);
	if(b<c)
		return 0;
	if(b<=d)
		return b-c+1;
	return d-c+1;
}

int main(){
	int q, t, answer = 0;
	scanf("%d%d", &q, &t);
	multiset<array<int, 3>> S;
	int id = 0;
	while(q--){
		int op;
		scanf("%d", &op);
		if(op==1){
			int a, b;
			scanf("%d%d", &a, &b);
			int l = a^(t*answer), r = b^(t*answer);
			if(l>r)
				swap(l, r);
			id++;
			S.insert({id, l, r});
		}
		else if(op==2){
			int need;
			scanf("%d", &need);
			tr(it, S)
				if((*it)[0]==need){
					S.erase(it);
					break;
				}
		}
		else{
			int a, b, k;
			scanf("%d%d%d", &a, &b, &k);
			int l = a^(t*answer), r = b^(t*answer);
			if(l>r)
				swap(l, r);
			answer = 0;
			for(auto i : S)
				answer += f(l, r, i[1], i[2])>=k;
			printf("%d\n", answer);
		}
	}
	return 0;
}

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%d%d", &q, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~
segments.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%d", &op);
      |   ~~~~~^~~~~~~~~~~
segments.cpp:36:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |    scanf("%d%d", &a, &b);
      |    ~~~~~^~~~~~~~~~~~~~~~
segments.cpp:45:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |    scanf("%d", &need);
      |    ~~~~~^~~~~~~~~~~~~
segments.cpp:54:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |    scanf("%d%d%d", &a, &b, &k);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...