Submission #1110292

#TimeUsernameProblemLanguageResultExecution timeMemory
1110292KasymKSegments (IZhO18_segments)C++17
7 / 100
5062 ms8352 KiB
#include "bits/stdc++.h"
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
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(){
	// freopen("file.txt", "r", stdin);
	int q, t, answer = 0;
	scanf("%d%d", &q, &t);
	multiset<array<int, 3>> S;
	int id = 0;
	unordered_map<int, pii> press;
	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++;
			press[id] = {l, r};
			S.insert({id, l, r});
		}
		else if(op==2){
			int need;
			scanf("%d", &need);
			pii P = press[need];
			S.erase({need, P.ff, P.ss});
		}
		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:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("O3")
      | 
segments.cpp:4: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    4 | #pragma GCC optimization ("unroll-loops")
      | 
segments.cpp: In function 'int main()':
segments.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  scanf("%d%d", &q, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~
segments.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   scanf("%d", &op);
      |   ~~~~~^~~~~~~~~~~
segments.cpp:41:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |    scanf("%d%d", &a, &b);
      |    ~~~~~^~~~~~~~~~~~~~~~
segments.cpp:51:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |    scanf("%d", &need);
      |    ~~~~~^~~~~~~~~~~~~
segments.cpp:57:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |    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...