답안 #937340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937340 2024-03-03T22:24:01 Z amirhoseinfar1385 Zoltan (COCI16_zoltan) C++17
42 / 140
22 ms 3816 KB
#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;
}
long long n,all[maxn],res,ted;

void vorod(){
	cin>>n;
	for(long long i=0;i<n;i++){
		cin>>all[i];
	}
	if(n>20){
		assert(0);
	}
}

void solve(){
	for(long long i=1;i<(1<<n);i++){
		long long sz=__builtin_popcount(i);
		if(sz<res){
			continue;
		}
		long long f=1,mx=-1e9-5,mn=1e9+5;
		for(long long j=0;j<n;j++){
			if((i>>j)&1){
				if(all[j]<=mx&&all[j]>=mn){
					f=0;
					break;
				}
				mn=min(mn,all[j]);
				mx=max(mx,all[j]);
			}
		}
		if(f){
			if(sz==res){
				ted++;
			}else{
				res=sz;
				ted=1;
			}
		}
	}
}

void khor(){
	ted=1ll*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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 348 KB Output is correct
2 Correct 18 ms 348 KB Output is correct
3 Correct 15 ms 460 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 8 ms 348 KB Output is correct
7 Runtime error 1 ms 604 KB Execution killed with signal 6
8 Runtime error 1 ms 604 KB Execution killed with signal 6
9 Runtime error 1 ms 604 KB Execution killed with signal 6
10 Runtime error 1 ms 604 KB Execution killed with signal 6
11 Runtime error 12 ms 2916 KB Execution killed with signal 6
12 Runtime error 10 ms 2648 KB Execution killed with signal 6
13 Runtime error 10 ms 2652 KB Execution killed with signal 6
14 Runtime error 12 ms 2652 KB Execution killed with signal 6
15 Runtime error 14 ms 3164 KB Execution killed with signal 6
16 Runtime error 22 ms 3596 KB Execution killed with signal 6
17 Runtime error 14 ms 3676 KB Execution killed with signal 6
18 Runtime error 14 ms 3772 KB Execution killed with signal 6
19 Runtime error 14 ms 3816 KB Execution killed with signal 6
20 Runtime error 14 ms 3676 KB Execution killed with signal 6