제출 #118252

#제출 시각아이디문제언어결과실행 시간메모리
118252baluteshihFish (IOI08_fish)C++14
70 / 100
3088 ms39644 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; const ll INF=1e9; ll MOD; pll fish[500005]; vector<pll> pl[500005],place; bitset<500005> vis; ll cnt[500005],bound[500005]; int main() {jizz ll n,k,ans=0,tmp,num,nw; cin >> n >> k >> MOD,nw=n-1; for(int i=0;i<n;++i) cin >> fish[i].F >> fish[i].S,++cnt[fish[i].S]; sort(fish,fish+n); for(int i=0;i<n;++i) pl[fish[i].S].pb(MP(fish[i].F,1)); for(int i=1;i<=k;++i) place.pb(MP(pl[i].back().F,i)); sort(ALL(place)); for(int i=n-1;i>=0;--i) if(!vis[fish[i].S]) { vector<pll> v; vis[fish[i].S]=1,tmp=1; while(nw>=0&&fish[nw].F*2>fish[i].F) --cnt[fish[nw].S],--nw; for(int j=0,t=0;j<k;++j) { while(t<pl[fish[i].S].size()&&pl[fish[i].S][t].F*2<=place[j].F) ++t; bound[place[j].S]=t+1; } for(int j=1;j<=k;++j) if(!vis[j]) { tmp=tmp*(cnt[j]+1)%MOD; if(cnt[j]==0) pl[j].back().S=pl[j].back().S*bound[j]%MOD; else if(cnt[j]<pl[j].size()) pl[j][cnt[j]-1].S=pl[j][cnt[j]-1].S*bound[j]%MOD; } num=1,tmp=tmp*pl[fish[i].S].back().S%MOD; ans=(ans+tmp)%MOD; for(int j=0;j<pl[fish[i].S].size()&&pl[fish[i].S][j].F*2<=fish[i].F;++j) tmp=tmp*pl[fish[i].S][j].S%MOD,ans=(ans+tmp)%MOD; } cout << ans << "\n"; }

컴파일 시 표준 에러 (stderr) 메시지

fish.cpp: In function 'int main()':
fish.cpp:44:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(t<pl[fish[i].S].size()&&pl[fish[i].S][t].F*2<=place[j].F)
           ~^~~~~~~~~~~~~~~~~~~~~
fish.cpp:53:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      else if(cnt[j]<pl[j].size())
              ~~~~~~^~~~~~~~~~~~~
fish.cpp:58: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].F*2<=fish[i].F;++j)
                ~^~~~~~~~~~~~~~~~~~~~~
fish.cpp:25:19: warning: variable 'num' set but not used [-Wunused-but-set-variable]
  ll n,k,ans=0,tmp,num,nw;
                   ^~~
#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...