Submission #118186

#TimeUsernameProblemLanguageResultExecution timeMemory
118186baluteshihFish (IOI08_fish)C++14
0 / 100
3102 ms37952 KiB
#include <bits/stdc++.h> #define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define pb push_back #define ET cout << "\n" #define MEM(i,j) memset(i,j,sizeof i) #define F first #define S second #define MP make_pair #define ALL(v) v.begin(),v.end() #define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;} using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; ll MOD; pll fish[500005]; vector<ll> pl[500005]; bitset<500005> vis; ll cnt[500005]; int main() {jizz ll n,k,ans=0,tmp,num; cin >> n >> k >> MOD; for(int i=0;i<n;++i) cin >> fish[i].F >> fish[i].S; sort(fish,fish+n); for(int i=0;i<n;++i) pl[fish[i].S].pb(fish[i].F); for(int i=n-1;i>=0;--i) if(!vis[fish[i].S]) { vis[fish[i].S]=1,tmp=1; for(int j=1;j<=k;++j) cnt[j]=0; for(int j=0;j<n&&fish[j].F*2<=fish[i].F;++j) ++cnt[fish[j].S]; for(int j=1;j<=k;++j) if(!vis[j]) tmp=tmp*(cnt[j]+1)%MOD; num=1; for(int j=0;j<pl[fish[i].S].size()&&pl[fish[i].S][j]*2<=fish[i].F;++j) ++num; ans=(ans+tmp*num)%MOD; } cout << ans << "\n"; }

Compilation message (stderr)

fish.cpp: In function 'int main()':
fish.cpp:43:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<pl[fish[i].S].size()&&pl[fish[i].S][j]*2<=fish[i].F;++j)
                ~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...