Submission #898410

# Submission time Handle Problem Language Result Execution time Memory
898410 2024-01-04T15:57:58 Z abcvuitunggio Fish (IOI08_fish) C++17
49 / 100
3000 ms 32696 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,k,m,res;
pair <int, int> f[500001];
map <int, int> pos,ch,ban,cnt;
int32_t main(){
    ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
    cin >> n >> k >> m;
    for (int i=0;i<n;i++){
        cin >> f[i].first >> f[i].second;
        if (!pos.count(f[i].second))
            pos[f[i].second]=f[i].first;
        pos[f[i].second]=min(pos[f[i].second],f[i].first);
    }
    sort(f,f+n);
    for (int i=n-1;i>=0;i--){
        if (ch.count(f[i].second))
            continue;
        for (int j=n-1;j>i;j--)
            if (f[j].first>=pos[f[i].second]*2)
                ban[f[j].second]=1;
        for (int j=0;j<i;j++)
            if (f[j].first*2<=f[i].first)
                cnt[f[j].second]++;
        int x=1;
        ban[f[i].second]=1;
        for (auto [i,j]:cnt)
            if (!ban.count(i))
                x=x*(j+1)%m;
        res=(res+x*(cnt[f[i].second]+1))%m;
        ch[f[i].second]=i;
        int l=0;
        for (int j=0;j<n;j++)
            if (f[j].first*2>f[i].first&&f[j].second==f[i].second){
                l=f[j].first;
                break;
            }
        int y=1;
        for (int j=i+1;j<n;j++)
            if (f[j].first>=pos[f[i].second]*2&&l*2>f[j].first&&ch[f[j].second]==j)
                y=y*(cnt[f[j].second]+1)%m;
        res=(res+x*(y+m-1))%m;
        ban.clear();
        cnt.clear();
    }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 240 ms 8264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 982 ms 4984 KB Output is correct
2 Correct 739 ms 7908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 600 KB Output is correct
2 Correct 384 ms 600 KB Output is correct
3 Correct 543 ms 1244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3030 ms 7256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3057 ms 8768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3068 ms 7408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3046 ms 9256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3063 ms 10520 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3071 ms 12884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3065 ms 25196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3006 ms 25768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3062 ms 32696 KB Time limit exceeded
2 Halted 0 ms 0 KB -