(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 #638230

#TimeUsernameProblemLanguageResultExecution timeMemory
638230ieeDrvca (COCI19_drvca)C++17
0 / 110
112 ms21580 KiB
// iee #include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <vector> #include <set> #include <map> #define rep(i, a, b) for (auto i = (a); i <= (b); ++i) #define per(i, a, b) for (auto i = (a); i >= (b); --i) #define fi first #define se second using ll = long long; using ull = unsigned long long; using namespace std; void work(int); template <class T> void read(T &x) { x = 0; int f = 1, ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + (ch - '0'), ch = getchar(); x *= f; } int main() { int TT = 1; // cin >> TT; rep(CAS, 1, TT) work(CAS); return 0; } const int N = 1e5 + 5; int n, a[N]; // int jb[N]; // void solve(int A1, int A2) { // memset(jb, 0, sizeof jb); // const int d = a[A2] - a[A1]; // jb[A1] = jb[A2] = 1; // int las = a[A2]; // rep(i, A2 + 1, n) { // if (a[i] - las == d) { // las = a[i]; // jb[i] = 1; // } // } // vector<int> B; // rep(i, 1, n) if (!jb[i]) B.push_back(a[i]); // for (int i = 2; i < B.size(); ++i) // if (B[i] - B[i - 1] != B[1] - B[0]) return; // cout << n - B.size() << '\n'; // rep(i, 1, n) if (jb[i]) cout << a[i] << ' '; // cout << '\n' << B.size() << '\n'; // for (int x: B) cout << x << ' '; // exit(0); // } void solve(int A1, int A2) { multiset<int> B, dB; rep(i, 1, n) if (i != A1 && i != A2) B.emplace(a[i]); vector<int> A{a[A1], a[A2]}; int las = -1, d = a[A2] - a[A1]; for (int v: B) { if (las != -1) dB.emplace(v - las); las = v; } int curA = a[A2] + d; while (A.size() < n) { if (*dB.begin() == *prev(dB.end())) { cout << A.size() << '\n'; for (int x: A) cout << x << ' '; cout << '\n' << B.size() << '\n'; for (int x: B) cout << x << ' '; exit(0); } auto it = B.find(curA); if (it == B.end()) return; if (it != B.begin()) dB.erase(dB.find(curA - *prev(it))); if (next(it) != B.end()) dB.erase(dB.find(*next(it) - curA)); B.erase(B.find(curA)); A.push_back(curA); curA += d; } } void work(int CASE) { cin >> n; rep(i, 1, n) cin >> a[i]; sort(a + 1, a + n + 1); if (n == 2) { cout << 1 << '\n' << a[1] << '\n' << 1 << '\n' << a[2]; return; } if ([&]() { rep(i, 2, n) if (a[i] - a[i - 1] != a[2] - a[1]) return 0; return 1; }()) { cout << n - 1 << '\n'; rep(i, 1, n - 1) cout << a[i] << ' '; cout << '\n' << 1 << '\n' << a[n]; return; } solve(1, 2), solve(2, 3), solve(1, 3); puts("-1"); }

Compilation message (stderr)

drvca.cpp: In function 'void solve(int, int)':
drvca.cpp:66:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |   while (A.size() < n) {
      |          ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...