제출 #776566

#제출 시각아이디문제언어결과실행 시간메모리
776566jamezzzFish (IOI08_fish)C++17
70 / 100
758 ms59480 KiB
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define fi first #define se second #define pb push_back #define sz(x) ((int)x.size()) #define all(x) x.begin(),x.end() #define LINF 1023456789123456789 typedef long long ll; typedef pair<int,int> ii; typedef pair<ll,int> li; #define maxn 500005 #define maxk 7005 int n,k,m,cnt[maxk],bad[maxk],pred[maxk]; bool num[maxk][maxk]; ll mn[maxn]; vector<ii> v; vector<int> stuff[maxk]; int main(){ sf("%d%d%d",&n,&k,&m); assert(n<=500000&&k<=7000); for(int i=0;i<n;++i){ int l,c; sf("%d%d",&l,&c); v.pb({l,c}); ++cnt[c]; } sort(all(v)); for(int i=0;i<n;++i){ int c=v[i].se; stuff[c].pb(i); } for(int i=1;i<=k;++i){ for(int j:stuff[i]){ if(v[j].fi*2<=v[stuff[i].back()].fi)++pred[i]; } } int ptr=n-1; ll ans=0; fill(mn,mn+n+1,1); for(int i=n-1;i>=0;--i){ int c=v[i].se; if(bad[c])continue; while(ptr>=0&&v[i].fi<2*v[ptr].fi){ --cnt[v[ptr].se]; --ptr; } vector<int> undo; for(int j=1;j<=k;++j){ if(c==j)continue; int x=bad[j]?cnt[c]:0; if(!bad[j]||num[c][j]){ mn[x+1]*=(cnt[j]+1); mn[x+1]%=m; undo.pb(x+1); } } ll add=1; for(int j=1;j<=cnt[c]+1;++j){ add*=mn[j]; add%=m; ans+=add; ans%=m; } for(int x:undo)mn[x]=1; for(int j=1;j<=k;++j){ if(pred[j]==cnt[j])num[j][c]=true; } bad[c]=1; //pf("%lld\n",ans); } pf("%lld\n",ans); }

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

fish.cpp: In function 'int main()':
fish.cpp:26:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  sf("%d%d%d",&n,&k,&m);
      |    ^
fish.cpp:30:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   sf("%d%d",&l,&c);
      |     ^
#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...