Submission #937335

# Submission time Handle Problem Language Result Execution time Memory
937335 2024-03-03T22:18:54 Z amirhoseinfar1385 Zoltan (COCI16_zoltan) C++17
7 / 140
14 ms 1300 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;
}
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=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();
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Correct 0 ms 348 KB Output is correct
5 Runtime error 1 ms 604 KB Execution killed with signal 11
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 0 ms 360 KB Output isn't correct
11 Incorrect 10 ms 860 KB Output isn't correct
12 Incorrect 9 ms 856 KB Output isn't correct
13 Incorrect 9 ms 860 KB Output isn't correct
14 Incorrect 10 ms 760 KB Output isn't correct
15 Incorrect 13 ms 968 KB Output isn't correct
16 Incorrect 14 ms 1216 KB Output isn't correct
17 Incorrect 12 ms 1116 KB Output isn't correct
18 Incorrect 12 ms 1156 KB Output isn't correct
19 Incorrect 13 ms 1300 KB Output isn't correct
20 Incorrect 12 ms 1116 KB Output isn't correct