Submission #1090280

# Submission time Handle Problem Language Result Execution time Memory
1090280 2024-09-18T07:14:53 Z peacebringer1667 Fish (IOI08_fish) C++17
4 / 100
111 ms 16976 KB
#include<bits/stdc++.h>
#define ll long long
#define ldb long double
#define fi first
#define se second
#define sza(a) (int)a.size()
#define pir pair<int,int>
#define pirll pair<ll,ll>
using namespace std;
const int maxn = 5e5 + 5;
int modu;

void add(int &x,int y){
	x %= modu;
	y %= modu;
	x = (x + y) % modu; 
}

int lst[maxn],dp[maxn],pre[maxn];
pir a[maxn];

void solve(int n,int k){
	int p = 0;
	for (int i = 1 ; i <= n ; i++){
		int val = a[i].fi,type = a[i].se;
		while (val >= a[p].fi * 2) p++;
		p--;
		
		if (!lst[type])
			dp[i] = (pre[p] + 1) % modu;
		else
		    dp[i] = (pre[p] - pre[lst[type]]) % modu;
		
		lst[type] = p;
		pre[i] = (pre[i - 1] + dp[i]) % modu;
	}
	
	pre[n] %= modu;
	pre[n] += modu;
	pre[n] %= modu;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	int n,k;
	cin >> n >> k >> modu;
	for (int i = 1 ; i <= n ; i++) cin >> a[i].fi >> a[i].se;
	sort(a + 1,a + 1 + n);
	solve(n,k);
	
	cout << pre[n];

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 5972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 9044 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 14356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 9300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 13772 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 15572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 12880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 15184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 94 ms 13140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 16976 KB Output isn't correct
2 Halted 0 ms 0 KB -