Submission #1019557

# Submission time Handle Problem Language Result Execution time Memory
1019557 2024-07-11T03:40:53 Z vjudge1 Fish (IOI08_fish) C++17
63 / 100
3000 ms 39508 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
int mod=0,ans,cnt[500010],cnt2[500010];
vector<int>S[500010];
inline int cntof(int i,int j){
    return lower_bound(S[j].begin(),S[j].end(),S[i].back()+2>>1)-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;
signed 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=k;j>i;j--)
            v.push_back(j);
        for(int j=1;j<=k;j++)
            cnt[j]=cntof(i,j);
        cnt[i]--;
        dothestuf(v,1,k);
        int kv=S[i][cnt[i]+1];
        for(auto x:v)
            if(S[x].back()>=2*kv)
                v2.push_back(x);
            else break;
        dothestuf(v2,-1,k);
        cnt[i]++;
        dothestuf(v2,1,k);
    }
    cout<<ans;
}

Compilation message

fish.cpp: In function 'long long int cntof(long long int, long long int)':
fish.cpp:7:59: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    7 |     return lower_bound(S[j].begin(),S[j].end(),S[i].back()+2>>1)-S[j].begin();
      |                                                ~~~~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 15960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 16128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 15964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 15964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 15960 KB Output is correct
2 Correct 16 ms 15964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 15960 KB Output is correct
2 Correct 107 ms 25600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 15960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 16260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 136 ms 20948 KB Output is correct
2 Correct 136 ms 22080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 886 ms 16260 KB Output is correct
2 Correct 435 ms 16220 KB Output is correct
3 Correct 719 ms 16216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 783 ms 23676 KB Output is correct
2 Correct 1173 ms 27248 KB Output is correct
3 Correct 1259 ms 27732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1000 ms 27504 KB Output is correct
2 Correct 1374 ms 28392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2007 ms 24144 KB Output is correct
2 Execution timed out 3061 ms 27772 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3010 ms 27140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3050 ms 30704 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3055 ms 28324 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3067 ms 36304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3034 ms 35272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3043 ms 39508 KB Time limit exceeded
2 Halted 0 ms 0 KB -