| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1292951 | binminh01 | Watermelon (INOI20_watermelon) | C++20 | 2094 ms | 1528 KiB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
#define sz(a) (int)a.size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define eb emplace_back
#define open(s) freopen(s, "r", stdin)
#define write(s) freopen(s, "w", stdout)
using pii = pair<int, int>;
using pll = pair<ll, ll>;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vdo;
typedef vector<vdo> vvdo;
typedef vector<string> vs;
typedef vector<pii> vpair;
typedef vector<vpair> vvpair;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi, greater<int>> pqg;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vll, greater<ll>> pqgll;
#define For(i, a, b) for (auto i = (a); i < (b); ++i)
#define FOR(i, a, b) for (auto i = (a); i <= (b); ++i)
#define Fore(i, a, b) for (auto i = (a); i >= (b); --i)
#define trav(i, a) for (auto &i: a)
vi cal(vi a) {
vi p(sz(a)); iota(all(p), 0);
vi b(sz(a), -1);
for (int t = 1;; ++t) {
vi q;
For(i,0,sz(p)-1){
if (a[p[i]] > a[p[i + 1]]) q.pb(p[i]);
else b[p[i]] = t;
}
if (sz(q) == sz(p) - 1) break;
q.pb(p.back()); p.swap(q);
}
return b;
}
int main() {
if (fopen("watermelon.inp", "r")) freopen("watermelon.inp", "r", stdin), freopen("watermelon.out", "w", stdout);
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
int n, k; cin >> n >> k;
vi b(n);
For(i,0,n) cin >> b[i];
vi p(n); iota(all(p), 1);
do {
if (cal(p) == b) {
if (--k == 0) {
For(i,0,n) cout << p[i] << ' ';
return 0;
}
}
} while (next_permutation(all(p)));
cout << -1;
}
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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
