# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
900426 |
2024-01-08T09:45:10 Z |
n3rm1n |
Karte (COCI18_karte) |
C++17 |
|
1000 ms |
10500 KB |
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 5e5 + 10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, k;
int a[MAXN];
void read()
{
cin >> n >> k;
for (int i = 1; i <= n; ++ i)
cin >> a[i];
}
int p[MAXN], used[MAXN];
void check()
{
int cnt_false = 0;
for (int i = 1; i <= n; ++ i)
{
if(cnt_false < p[i])
{
cnt_false ++;
}
}
if(cnt_false == k)
{
for (int i = n; i >= 1; -- i)
cout << p[i] << " ";
cout << endl;
//exit(0);
}
}
void gen(int pos, int cnt_false)
{
if(cnt_false > k)return;
if(cnt_false + n - pos + 1 < k)return;
if(pos > n)
{
// cout << cnt_false << endl;
if(cnt_false == k)
{
for (int i = n; i >= 1; -- i)
cout << p[i] << " ";
cout << endl;
exit(0);
}
return;
}
for (int i = 1; i <= n; ++ i)
{
if(!used[i])
{
used[i] = 1;
p[pos] = a[i];
if(a[i] <= cnt_false)gen(pos+1, cnt_false);
else gen(pos+1, cnt_false+1);
used[i] = 0;
}
}
}
int main()
{
speed();
read();
gen(1, 0);
cout << -1 << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
4444 KB |
Output is correct |
2 |
Execution timed out |
1079 ms |
4444 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
11 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1073 ms |
4444 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1041 ms |
4440 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1004 ms |
4696 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
4712 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1045 ms |
9264 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1031 ms |
9592 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1026 ms |
10500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |