이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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];
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(MP(fish[i].F,1));
for(int i=n-1;i>=0;--i)
if(!vis[fish[i].S])
{
vector<pll> v;
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;
if(cnt[j]==0) pl[j].back().S=pl[j].back().S*(upper_bound(ALL(pl[fish[i].S]),MP(pl[j].back().F/2,INF))-pl[fish[i].S].begin()+1)%MOD;
else if(cnt[j]<pl[j].size())
pl[j][cnt[j]-1].S=pl[j][cnt[j]-1].S*(upper_bound(ALL(pl[fish[i].S]),MP(pl[j].back().F/2,INF))-pl[fish[i].S].begin()+1)%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:46:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
else if(cnt[j]<pl[j].size())
~~~~~~^~~~~~~~~~~~~
fish.cpp:51: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;
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |