# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
495289 |
2021-12-18T08:41:28 Z |
kingline |
Gift (IZhO18_nicegift) |
C++17 |
|
2000 ms |
1976 KB |
#include <bits/stdc++.h>
#define pb push_back
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(data) data.begin() , data.end()
#define endl '\n'
//freopen("nenokku_easy.in", "r", stdin);
//freopen("nenokku_easy.out", "w", stdout);
#define int long long
#define pii pair < int, int >
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int n, k, rel, a[N], b[N];
vector < pair < int, pii > > path;
void rec() {
bool ok = 1;
for(int i = 1; i <= n; i++) {
if(b[i] > a[i]) return;
if(b[i] < a[i]) ok = 0;
}
if(ok) {
cout << path.size() << endl;
for(int i = 0; i < path.size(); i++) {
cout << path[i].first << " " << path[i].second.first << " " << path[i].second.second << endl;
}
exit(0);
}
for(int i = 1; i <= n; i++) {
for(int j = i + 1; j <= n; j++) {
for(int w = rel; w > 0; w--) {
path.pb({w, {i, j}});
b[i] += w;
b[j] += w;
rec();
b[i] -= w;
b[j] -= w;
path.pop_back();
}
}
}
}
main() {
/*ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);*/
cin >> n >> k;
for(int i = 1; i <= n; i++) {
cin >> a[i];
rel = max(rel, a[i]);
}
rec();
cout << -1;
}
/*
5
2 8 5 1 10
5
2 3 5 3
2 5 3 3
1 4 4
2 3 4 2
1 1 2
*/
Compilation message
nicegift.cpp: In function 'void rec()':
nicegift.cpp:27:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i = 0; i < path.size(); i++) {
| ~~^~~~~~~~~~~~~
nicegift.cpp: At global scope:
nicegift.cpp:47:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
47 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
1 ms |
204 KB |
n=3 |
3 |
Correct |
0 ms |
204 KB |
n=3 |
4 |
Correct |
0 ms |
204 KB |
n=4 |
5 |
Correct |
1 ms |
204 KB |
n=4 |
6 |
Correct |
1 ms |
204 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
1 ms |
204 KB |
n=3 |
3 |
Correct |
0 ms |
204 KB |
n=3 |
4 |
Correct |
0 ms |
204 KB |
n=4 |
5 |
Correct |
1 ms |
204 KB |
n=4 |
6 |
Correct |
1 ms |
204 KB |
n=2 |
7 |
Correct |
1 ms |
204 KB |
n=5 |
8 |
Execution timed out |
2080 ms |
204 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
1 ms |
204 KB |
n=3 |
3 |
Correct |
0 ms |
204 KB |
n=3 |
4 |
Correct |
0 ms |
204 KB |
n=4 |
5 |
Correct |
1 ms |
204 KB |
n=4 |
6 |
Correct |
1 ms |
204 KB |
n=2 |
7 |
Correct |
1 ms |
204 KB |
n=5 |
8 |
Execution timed out |
2080 ms |
204 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
54 ms |
1976 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
1 ms |
204 KB |
n=3 |
3 |
Correct |
0 ms |
204 KB |
n=3 |
4 |
Correct |
0 ms |
204 KB |
n=4 |
5 |
Correct |
1 ms |
204 KB |
n=4 |
6 |
Correct |
1 ms |
204 KB |
n=2 |
7 |
Correct |
1 ms |
204 KB |
n=5 |
8 |
Execution timed out |
2080 ms |
204 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |