Submission #898409

# Submission time Handle Problem Language Result Execution time Memory
898409 2024-01-04T15:57:25 Z abcvuitunggio Fish (IOI08_fish) C++17
0 / 100
3000 ms 41044 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);
    cout << '\n';
    for (int i=0;i<n;i++)
        cout << f[i].first << ' ' << f[i].second << '\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 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 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 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 995 ms 7296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3057 ms 11400 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3049 ms 14824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3043 ms 11876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3046 ms 15448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3018 ms 18112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3023 ms 19900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3029 ms 32512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3043 ms 31316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 41044 KB Time limit exceeded
2 Halted 0 ms 0 KB -