제출 #1306581

#제출 시각아이디문제언어결과실행 시간메모리
1306581kduckpDrvca (COCI19_drvca)C++20
0 / 110
1096 ms7488 KiB
/* Author: duxp Version: 1 Created at: 2025-12-30 20:33 */ // ✅ Pragmas for Maximum Optimization in Competitive Programming #include <bits/stdc++.h> using namespace std; #define ll long long #define int long long #define pb push_back #define all(x) x.begin() + 1, x.end() #define nall(x) x.begin(), x.end() #define vi vector<int> #define pll pair<ll, ll> #define pii pair<int, int> #define fi first #define se second #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define debug(x) cerr << #x << " = " << (x) << endl #define debug2(x, y) cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl #define debug3(x, y, z) cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl #define trailingzero(x) __builtin_ctzll(x) #define cntbit1(x) __builtin_popcountll(x) #define leadingzero(x) __builtin_clzll(x) #define TDN signed main() #define KILL() exit(0) #define NAME "drvca" template <typename T> inline int getbit(T x, int k) { return (x >> k) & 1; } template <typename T> inline T onbit(T x, int k) { return x | (T(1) << k); } template <typename T> inline T offbit(T x, int k) { return x & ~(T(1) << k); } template <typename T> inline bool minimize(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> inline bool maximize(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } const ll INF = 1e18; const int MOD = 1000000007; const int MOD2 = 998244353; const int MAXN = 200000; bool ok(vi a) { if (a.size() == 0) return false; if (a.size() == 1) return true; int diff = a[1] - a[0]; for (int i = 1; i < (int)a.size(); i++) { if (a[i] - a[i - 1] != diff) return false; } return true; } TDN { fast; string fname = string(NAME); if (fopen((fname + ".inp").c_str(), "r")) { freopen((fname + ".inp").c_str(), "r", stdin); freopen((fname + ".out").c_str(), "w", stdout); } int n; cin >> n; vi a(n + 1); for (int i = 1; i <= n; i++) cin >> a[i]; sort(all(a)); vi diff; for (int i = 1; i <= n; i++) { diff.pb(a[i] - a[1]); } for (auto d : diff) { vector<bool> inA(n + 1, false); int last = a[1]; inA[1] = true; for (int j = 2; j <= n; j++) { if (a[j] - last == d) { last = a[j]; inA[j] = true; } } vi B; for (int j = 1; j <= n; j++) { if (!inA[j]) B.pb(a[j]); } if (ok(B)) { vi A; for (int j = 1; j <= n; j++) { if (inA[j]) A.pb(a[j]); } if (!ok(A) || A.size() + B.size() != n) continue; sort(nall(A)); sort(nall(B)); cout << A.size() << endl; for (auto x : A) cout << x << ' '; cout << endl; cout << B.size() << endl; for (auto x : B) cout << x << ' '; cout << endl; KILL(); } } cout << -1; KILL(); }

컴파일 시 표준 에러 (stderr) 메시지

drvca.cpp: In function 'int main()':
drvca.cpp:97:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   97 |         freopen((fname + ".inp").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drvca.cpp:98:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   98 |         freopen((fname + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...