QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#591347#4270. Double Attendancechenxinyang2006#0 0ms3980kbC++202.2kb2024-09-26 15:30:312024-09-26 15:30:31

Judging History

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

  • [2024-09-26 15:30:31]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3980kb
  • [2024-09-26 15:30:31]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
	if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
	if(x > y) x = y;
}

inline int popcnt(int x){
	return __builtin_popcount(x);
}

inline int ctz(int x){
	return __builtin_ctz(x);
}


/*ll power(ll p,int k = mod - 2){
	ll ans = 1;
	while(k){
		if(k % 2 == 1) ans = ans * p % mod;
		p = p * p % mod;
		k /= 2;	
	}
	return ans;
}*/
int n,m,K,V;
int a[2][2005];

int trans(int x,int y){
	if(x == y) return 0;
	return (x > 0);
}

int getnxt(int p,int s,int sp){
	while(s <= V){
		if(a[p][s] != a[p][s + 1] && (!sp || a[p][s + 1])) return s + 1;
		s++;
	}
	return V + 1;
}

int dp[2005][2][2];
void trans(int i){
	rep(p,0,1){
		per(q,1,0){
			if(dp[i][p][q] > V) continue;
			int s = dp[i][p][q];
			if(s + K <= V) chkmin(dp[i + trans(a[p ^ 1][s + K],q * a[p ^ 1][s])][p ^ 1][a[p][s] == a[p][s + K]],s + K);

			int t0 = getnxt(p ^ 1,s,0),t1 = getnxt(p,s,1);
			chkmin(dp[i][p][0],t0);
			chkmin(dp[i + 1][p][q],t1);
			if(t0 == t1) chkmin(dp[i + 1][p][0],t0);
		}
	}	
}

int main(){	
//	freopen("test.in","r",stdin);
	scanf("%d%d%d",&n,&m,&K);
	rep(i,1,n){
		int l,r;
		scanf("%d%d",&l,&r);
		rep(k,l,r - 1) a[0][k] = i;
		chkmax(V,r - 1);
	}
	rep(i,1,m){
		int l,r;
		scanf("%d%d",&l,&r);
		rep(k,l,r - 1) a[1][k] = i;
		chkmax(V,r - 1);
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0][0][0] = 0;
	rep(i,0,n + m){
		trans(i);
		trans(i);
/*		printf("i=%d\n",i);
		rep(p,0,1){
			rep(q,0,1) printf("(%d,%d) %d\n",p,q,dp[i][p][q]);
		}*/
	}
	int answer = 0;
	rep(i,0,n + m){
		rep(p,0,1){
			rep(q,0,1) if(dp[i][p][q] <= V) chkmax(answer,i);
		}
	}
	printf("%d\n",answer);
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 0ms
memory: 3876kb

input:

3 1 8
10 20
100 101
20 21
15 25

output:

3

result:

ok single line: '3'

Test #2:

score: 5
Accepted
time: 0ms
memory: 3832kb

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: 5
Accepted
time: 0ms
memory: 3980kb

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: 0
Wrong Answer
time: 0ms
memory: 3924kb

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: 0ms
memory: 3920kb

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%