Submission #118197

#TimeUsernameProblemLanguageResultExecution timeMemory
118197baluteshihFish (IOI08_fish)C++14
49 / 100
2619 ms65536 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],rec[3000][3000]; int main() {jizz ll n,k,ans=0,tmp,num,t; 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]) { vector<pll> v; //cout << 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,rec[fish[i].S][j]=cnt[j]+1; else if(j!=fish[i].S) v.pb(MP(rec[j][fish[i].S],cnt[j]+1)); num=1,t=0; sort(ALL(v)); while(t<v.size()&&v[t].F<=num) tmp=tmp*v[t].S%MOD,++t; ans=(ans+tmp)%MOD; //cout << tmp << " "; for(int j=0;j<pl[fish[i].S].size()&&pl[fish[i].S][j]*2<=fish[i].F;++j) { ++num; while(t<v.size()&&v[t].F<=num) tmp=tmp*v[t].S%MOD,++t; ans=(ans+tmp)%MOD; //cout << tmp << " "; } //ET; } cout << ans << "\n"; }

Compilation message (stderr)

fish.cpp: In function 'int main()':
fish.cpp:48:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(t<v.size()&&v[t].F<=num)
          ~^~~~~~~~~
fish.cpp:52: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)
                ~^~~~~~~~~~~~~~~~~~~~~
fish.cpp:55:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(t<v.size()&&v[t].F<=num)
           ~^~~~~~~~~
#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...