Submission #1019528

# Submission time Handle Problem Language Result Execution time Memory
1019528 2024-07-11T02:58:26 Z vjudge1 Fish (IOI08_fish) C++17
0 / 100
68 ms 7500 KB
#include<bits/stdc++.h>
using namespace std;
int mod=0,ans,cnt[7010],cnt2[7010];
vector<int>S[7010];
inline int cntof(int i,int j){
    return upper_bound(S[j].begin(),S[j].end(),S[i].back()/2)-S[j].begin();
}
void dothestuf(vector<int>bad,int k,int l){
    memcpy(cnt2,cnt,sizeof cnt);
    for(auto f:bad)
        cnt2[f]=0;
    long long x=1;
    for(int i=1;i<=l;i++) 
        x=(x*(cnt2[i]+1))%mod;
    ans=(ans+mod+x*k)%mod;
}
vector<int>order;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n,k;
    cin>>n>>k>>mod;
    for(int i=1;i<=n;i++){
        int a,b; cin>>a>>b;
        S[b].push_back(a);
    }
    for(int i=1;i<=k;i++)
        sort(S[i].begin(),S[i].end());
    sort(S+1,S+k+1,[](vector<int>a,vector<int>b){
        return a.back()<b.back();
    });
    for(int i=1;i<=k;i++){
        vector<int> v,v2;
        for(int j=i;j++<k;)
            v.push_back(j);
        for(int j=1;j<=k;j++)
            cnt[j]=cntof(i,j);
        dothestuf(v,1,k);
        int k=S[i][cnt[i]];
        for(auto x:v)
            if(S[x].back()<2*k)
                v2.push_back(x);
            else break;
        dothestuf(v2,-1,k);
        cnt[i]--;
        dothestuf(v2,1,k);
        v.clear();
        dothestuf(v,-1,k);
        cnt[i]++;
        dothestuf(v,1,k);
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 3796 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1116 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 58 ms 5316 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 68 ms 7500 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 50 ms 5372 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -