이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
int mod=0,ans,cnt[10010],cnt2[10010];
vector<int>S[10010];
inline int cntof(int i,int j){
return lower_bound(S[j].begin(),S[j].end(),S[i].back()+2>>1)-S[j].begin();
}
void dothestuf(vector<int>bad,int k,int l){
memcpy(cnt2,cnt,sizeof cnt);
for(auto f:bad)
cnt2[f]=0;
long long x=1;
for(int i=1;i<=l;i++)
x=(x*(cnt2[i]+1))%mod;
ans=(ans+mod+x*k)%mod;
}
vector<int>order;
signed main(){
cin.tie(0)->sync_with_stdio(0);
int n,k;
cin>>n>>k>>mod;
for(int i=1;i<=n;i++){
int a,b;cin>>a>>b;
S[b].push_back(a);
}
for(int i=1;i<=k;i++)
sort(S[i].begin(),S[i].end());
sort(S+1,S+k+1,[](vector<int>a,vector<int>b){
return a.back()<b.back();
});
for(int i=1;i<=k;i++){
vector<int> v,v2;
for(int j=k;j>i;j--)
v.push_back(j);
for(int j=1;j<=k;j++)
cnt[j]=cntof(i,j);
cnt[i]--;
dothestuf(v,1,k);
int kv=S[i][cnt[i]+1];
for(auto x:v)
if(S[x].back()>=2*kv)
v2.push_back(x);
else break;
dothestuf(v2,-1,k);
cnt[i]++;
dothestuf(v2,1,k);
}
cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
fish.cpp: In function 'long long int cntof(long long int, long long int)':
fish.cpp:7:59: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
7 | return lower_bound(S[j].begin(),S[j].end(),S[i].back()+2>>1)-S[j].begin();
| ~~~~~~~~~~~^~
# | 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... |