# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
685244 | 2023-01-23T17:57:51 Z | Farhan_HY | Drvca (COCI19_drvca) | C++14 | 27 ms | 3032 KB |
#include <bits/stdc++.h> #define int long long #define F first #define S second #define T int t; cin >> t; while(t--) #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; const int N = 1e5 + 5; const int M = 1e3 + 3; const int inf = 1e18; const int mod = 1e9 + 7; int n, a[N]; vector<int> v1, v2; bool ok(int i, int j) { v1.clear(); v2.clear(); int d = a[j] - a[i]; v1.push_back(a[i]); v1.push_back(a[j]); for(int k = 1; k <= j; k++) if (k != i && k != j) v2.push_back(a[k]); for(int k = j + 1; k <= n; k++) { if (a[k] - v1.back() == d) v1.push_back(a[k]); else v2.push_back(a[k]); } bool q = 1; for(int k = 1; k < v2.size(); k++) q &= (v2[k] - v2[k - 1] == v2[1] - v2[0]); return q; } main() { IOS cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; sort(a, a + n + 1); bool ans = 0; if (n == 2) { cout << 1 << '\n' << a[1] << "\n1\n" << a[2]; return 0; } for(int i = 1; i <= 2; i++) { for(int j = i + 1; j <= 3; j++) { ans |= ok(i, j); if (ans) break; } if (ans) break; } if (!ans) { cout << -1; return 0; } cout << v1.size() << '\n'; for(auto x: v1) cout << x << ' '; cout << '\n'; cout << v2.size() << '\n'; for(auto x: v2) cout << x << ' '; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Incorrect | 0 ms | 212 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Incorrect | 0 ms | 212 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 3000 KB | Output is correct |
2 | Correct | 25 ms | 3004 KB | Output is correct |
3 | Correct | 26 ms | 3016 KB | Output is correct |
4 | Correct | 23 ms | 3024 KB | Output is correct |
5 | Correct | 24 ms | 3012 KB | Output is correct |
6 | Correct | 24 ms | 3032 KB | Output is correct |
7 | Correct | 23 ms | 3004 KB | Output is correct |
8 | Correct | 26 ms | 2920 KB | Output is correct |
9 | Incorrect | 15 ms | 2648 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Incorrect | 0 ms | 212 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |