# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
937333 | amirhoseinfar1385 | Zoltan (COCI16_zoltan) | C++17 | 2 ms | 536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int maxn=200000+10,mod=1e9+7;
long long mypow(long long m,long long y){
if(y==0){
return 1;
}
long long p=mypow(m,(y>>1));
p*=p;
p%=mod;
if(y&1){
p*=m;
p%=mod;
}
return p;
}
int n,all[maxn],res,ted;
void vorod(){
cin>>n;
for(int i=0;i<n;i++){
cin>>all[i];
}
if(n>20){
exit(0);
}
}
void solve(){
for(int i=1;i<(1<<n);i++){
int sz=__builtin_popcount(i);
if(sz<res){
continue;
}
int f=1,mx=-1,mn=1e9+5;
for(int j=0;j<n;j++){
if((i>>j)&1){
if(all[i]<=mx&&all[i]>=mn){
f=0;
break;
}
mn=min(mn,all[j]);
mx=max(mn,all[j]);
}
}
if(f){
if(sz==res){
ted++;
}else{
res=sz;
ted=1;
}
}
}
}
void khor(){
ted=ted*mypow(2,n-res)%mod;
cout<<res<<" "<<ted<<endl;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("inp.txt","r",stdin);
vorod();
solve();
khor();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |