# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1237232 | alexandros | Magneti (COCI21_magneti) | C++20 | 1095 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main(){
int amount, amounts;
scanf("%d %d", &amount, &amounts);
vector<ll> radius(amount);
for(int i = 0; i < amount; i++){
scanf("%lld", &radius[i]);
}
if(amount > 10)
{
printf("123123");
return 0;
}
vector<int> idx(amount);
iota(idx.begin(), idx.end(), 0);
vector<bool> use(amounts);
fill(use.begin() + (amounts - amount), use.end(), true);
ll ans = 0;
do {
do {
vector<int> chosen;
chosen.reserve(amount);
for(int i = 0; i < amounts; i++){
if(use[i]) chosen.push_back(i);
}
bool ok = true;
for(int i = 0; i < amount && ok; i++){
for(int j = i+1; j < amount; j++){
int di = chosen[i], dj = chosen[j];
int d = abs(di - dj);
if(d < radius[idx[i]] || d < radius[idx[j]]){
ok = false;
break;
}
}
}
if(ok){
ans++;
if(ans >= MOD) ans -= MOD;
}
} while(next_permutation(use.begin(), use.end()));
fill(use.begin(), use.end(), false);
fill(use.begin() + (amounts - amount), use.end(), true);
} while(next_permutation(idx.begin(), idx.end()));
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | 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... |