# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1012112 |
2024-07-01T16:26:21 Z |
vjudge1 |
Fish (IOI08_fish) |
C++17 |
|
3000 ms |
26836 KB |
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair < int, int >
using namespace std;
const int N = 5e5+10, K = 5e5+10;
const int logN = 20, maxN = (1<<20), startpos = maxN-1;
int n, k, m;
pii ribe[N];
int najvecidrag[K];
int draginterval[K];
int cur;
int lowout[K];
int st[maxN<<1];
vector < int > dragulji;
int sol;
bool rip[K];
bool ripp[20][20];
int temp[20];
bool dragsort1( int a, int b ) {
if(najvecidrag[a] > najvecidrag[b]) return 1;
return 0;
}
bool dragsort2( int a, int b ) {
if(lowout[a] > lowout[b]) return 1;
return 0;
}
int add( int a, int b ) {
return (a + b >= m) ? a+b-m : a+b;
}
int mul( int a, int b ) {
return (ll) a * b % m;
}
inline void merge( int i ) {
st[i] = mul(st[i*2+1], st[i*2+2]);
return;
}
inline void update( int i, int v ) {
i += startpos;
st[i] += v;
while(i != 0) {
i = (i - 1) / 2;
merge(i);
}
return;
}
int main( void ) {
FIO
cin >> n >> k >> m;
for(int i = 0; i < n; i++) {
cin >> ribe[i].F >> ribe[i].S;
ribe[i].S--;
}
sort(ribe, ribe + n);
cur = 0;
for(int i = 0; i < n; i++) {
najvecidrag[ribe[i].S] = i;
while(ribe[cur].F * 2 <= ribe[i].F) {
cur++;
}
draginterval[ribe[i].S] = cur;
lowout[ribe[i].S] = n;
}
for(int i = 0; i < n; i++) {
if(i >= draginterval[ribe[i].S]) {
lowout[ribe[i].S] = min(lowout[ribe[i].S], i);
}
}
for(int i = 0; i < maxN<<1; i++) st[i] = 1;
for(int i = 0; i < n; i++) {
update(ribe[i].S, 1);
}
for(int i = 0; i < k; i++) {
dragulji.pb(i);
}
sort(dragulji.begin(), dragulji.end(), dragsort1);
cur = n-1;
for(int i = 0; i < k; i++) {
// cout << st[startpos+0] << " " << st[startpos+1] << " " << st[startpos+2] << "\n";
while(cur >= 0 && draginterval[dragulji[i]] <= cur) {
if(!rip[dragulji[i]])update(ribe[cur].S, -1);
cur--;
}
update(dragulji[i], -1);
sol = add(sol, st[0]);
update(dragulji[i], 1-st[dragulji[i] + startpos]);
rip[dragulji[i]] = 1;
}
for(int i = 0; i < k; i++) rip[i] = 0;
// cout << sol << "\n";
cur = n-1;
for(int i = 0; i < maxN<<1; i++) st[i] = 1;
for(int i = 0; i < n; i++) {
update(ribe[i].S, 1);
}
for(int i = 0; i < k; i++) {
for(int j = 0; j < k; j++) {
if(draginterval[i] > lowout[j]) {
ripp[j][i] = 1;
}
if(i==j) ripp[j][i] = 1;
}
}
// cout << st[startpos+0] << " " << st[startpos+1] << " " << st[startpos+2] << "\n\n\n";
for(int i = 0; i < k; i++) {
while(cur >= 0 && draginterval[dragulji[i]] <= cur) {
if(!rip[dragulji[i]])update(ribe[cur].S, -1);
cur--;
}
// cout << st[startpos+0] << " " << st[startpos+1] << " " << st[startpos+2] << "\n";
for(int j = 0; j < k; j++) {
if(ripp[dragulji[i]][j]) {
temp[j] = st[j + startpos] - 1;
update(j, - temp[j]);
}
}
sol = add(sol, st[0]);
// cout << st[startpos+0] << " " << st[startpos+1] << " " << st[startpos+2] << "\n\n";
for(int j = 0; j < k; j++) {
if(ripp[dragulji[i]][j]) {
update(j, temp[j]);
}
}
}
cout << sol;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
16728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
16732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
16732 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
16732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
16728 KB |
Output is correct |
2 |
Incorrect |
6 ms |
16732 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
16732 KB |
Output is correct |
2 |
Incorrect |
303 ms |
24784 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
16732 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
15068 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
15528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
15196 KB |
Output is correct |
2 |
Incorrect |
154 ms |
13192 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
505 ms |
19536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
792 ms |
23124 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1480 ms |
17748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3040 ms |
21052 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3056 ms |
24664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3009 ms |
23096 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3059 ms |
26748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3075 ms |
23504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3043 ms |
26836 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |