QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#861922#9982. Staircase Museumucup-team191#WA 7ms5860kbC++231.1kb2025-01-18 20:40:122025-01-18 20:40:17

Judging History

This is the latest submission verdict.

  • [2025-01-18 20:40:17]
  • Judged
  • Verdict: WA
  • Time: 7ms
  • Memory: 5860kb
  • [2025-01-18 20:40:12]
  • Submitted

answer

#include <bits/stdc++.h>
#define X first
#define Y second
#define PB push_back
#define x first
#define y second
#define pb push_back
#define all(a) begin(a),end(a)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
using pii=pair<int,int>;

const int N = 5e5 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
const char en='\n';
const ll LLINF=1ll<<60;

int t,n,l[N],r[N];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>t;
	while (t--)
	{
		cin>>n;
		for (int i=0;i<n;++i) cin>>l[i]>>r[i];
		set<pii> sr,sl;
		sr.insert({0,l[0]});
		for (int i=1;i<n;++i) if (r[i]!=r[i-1]) sr.insert({i,r[i-1]});
		sl.insert({0,l[0]});
		for (int i=1;i<n;++i) if (l[i]!=l[i-1]) sl.insert({i,l[i]});
		//sl.insert({n,l[n-1]});
		int odg=sl.size()+sr.size();
		/*for (auto x: sl) cout<<x.x<<' '<<x.y<<en;
		cout<<en;
		for (auto x: sr) cout<<x.x<<' '<<x.y<<en;*/
		for (auto x: sr)
		{
			while (sl.size() && sl.begin()->x<x.x) sl.erase(sl.begin());
			if (sl.size() && sl.begin()->y<=x.y) --odg,sl.erase(sl.begin());
		}
		cout<<odg<<en;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5860kb

input:

4
3
1 2
1 3
1 3
3
1 2
2 3
3 3
3
1 1
1 3
3 3
4
1 2
2 3
3 4
4 5

output:

2
3
3
4

result:

ok 4 number(s): "2 3 3 4"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5732kb

input:

1
1
1 1000000000

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Wrong Answer
time: 7ms
memory: 5860kb

input:

9653
1
1 1
2
1 1
1 1
3
1 1
1 1
1 1
4
1 1
1 1
1 1
1 1
5
1 1
1 1
1 1
1 1
1 1
6
1 1
1 1
1 1
1 1
1 1
1 1
6
1 2
1 2
1 2
1 2
1 2
2 2
6
1 1
1 1
1 1
1 1
1 1
1 2
6
1 2
1 2
1 2
1 2
1 2
2 3
5
1 2
1 2
1 2
1 2
2 2
6
1 2
1 2
1 2
1 2
2 2
2 2
6
1 3
1 3
1 3
1 3
2 3
3 3
6
1 2
1 2
1 2
1 2
2 2
2 3
6
1 3
1 3
1 3
1 3
2 3...

output:

1
1
1
1
1
1
2
2
2
2
2
3
3
3
2
2
2
3
3
3
3
2
2
3
3
3
3
3
2
2
2
3
3
3
3
3
4
4
4
3
3
3
4
4
4
4
3
3
4
4
4
4
4
2
2
2
2
3
3
3
3
3
3
2
2
3
3
3
3
3
3
3
3
3
3
4
4
3
3
4
4
4
4
3
3
3
4
4
3
3
4
4
4
4
3
3
4
4
4
3
3
4
4
4
4
4
2
2
2
3
3
3
3
3
3
3
3
3
4
4
4
4
4
4
4
3
3
3
4
4
3
3
4
4
4
4
3
3
4
4
4
4
4
4
4
4
4
3
3
4
...

result:

wrong answer 20th numbers differ - expected: '2', found: '3'