(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #685234

#TimeUsernameProblemLanguageResultExecution timeMemory
685234Farhan_HYDrvca (COCI19_drvca)C++14
0 / 110
30 ms4144 KiB
#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]; bool vis[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]); } if (v2.size() == 0) { v2.push_back(v1.back()); v1.pop_back(); } bool q = 1; if (v2.size() == 1) return 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); if (ok(1, 2)) {} else if (ok(1, 3)) {} else if (ok(2, 3)) {} else { 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 (stderr)

drvca.cpp: In function 'bool ok(long long int, long long int)':
drvca.cpp:35:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int k = 1; k < v2.size(); k++)
      |                    ~~^~~~~~~~~~~
drvca.cpp: At global scope:
drvca.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...