QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#103208#4270. Double AttendanceCrysfly0 3ms12824kbC++111.7kb2023-05-04 19:22:552023-05-04 19:22:58

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-04 19:22:58]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:12824kb
  • [2023-05-04 19:22:55]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 600005
#define inf 0x3f3f3f3f

int n[2],k;
vector<pii>s[2];
int f[maxn][2][2],res;

// 当前所在教室,另一个教室有没有看过 

vector<pii>::iterator get(int j,int x){
	return lower_bound(s[j].begin(),s[j].end(),mkp(x+1,0));
}

signed main()
{
	n[0]=read(),n[1]=read(),k=read();
	s[0].pb(mkp(-1,-1)),s[1]=s[0];
	For(o,0,1)For(i,1,n[o]){
		int l=read(),r=read()-1;
		s[o].pb(mkp(l,r));
	}
	For(o,0,1)sort(s[o].begin(),s[o].end());
	memset(f,63,sizeof f);
	bool qwq=s[0].size()&&s[0][0].fi==0;
	f[qwq][0][0]=0;
	For(i,0,n[0]+n[1]){
		For(j,0,1)For(t,0,1)if(f[i][j][t]<inf){
			res=i;
			int x=f[i][j][t];
		//	cout<<"i,j,t "<<i<<" "<<j<<" "<<t<<' '<<f[i][j][t]<<"\n"; 
			auto it=get(j,x);
			auto it1=--get(!j,x);
			if(it!=s[j].end()){
				auto it2=--get(!j,it->fi);
				bool same=it1==it2;
				f[i+1][j][t&same]=min(f[i+1][j][t&same],it->fi);
			}
			auto nxt=--get(!j,x+k);
			if((nxt==it1 && t) || (nxt->se<x+k)) ++nxt;
			if(nxt!=s[!j].end()){
		//		cout<<"it->fi "<<nxt->fi<<"\n";
				auto it2=get(j,max(nxt->fi,x+k));
				bool same=it2==it;
				f[i+1][!j][same]=min(f[i+1][!j][same],max(nxt->fi,x+k));
			}
		}
		if(res<i)break;
	}
	cout<<res;
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 3ms
memory: 12824kb

input:

3 1 8
10 20
100 101
20 21
15 25

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 2ms
memory: 12756kb

input:

1 5 3
1 100
1 2
2 3
3 4
4 5
5 6

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 2ms
memory: 12724kb

input:

10 10 5
4 9
43 48
69 70
70 72
52 67
75 83
100 103
103 1501
10 27
28 40
5 7
27 29
30 39
40 42
42 45
67 80
0 5
45 59
10 20
22 23

output:

18

result:

ok single line: '18'

Test #4:

score: -5
Wrong Answer
time: 0ms
memory: 12760kb

input:

1 1 1
0 1
0 1

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #104:

score: 0
Wrong Answer
time: 3ms
memory: 12760kb

input:

1 1 1
0 1
0 1

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%