Submission #445579

# Submission time Handle Problem Language Result Execution time Memory
445579 2021-07-18T17:48:57 Z hgmhc Drvca (COCI19_drvca) C++17
0 / 110
36 ms 3364 KB
#include <bits/stdc++.h>
#define REP(i,a,b) for (auto i = (a); i <= (b); ++i)
#define PER(i,a,b) for (auto i = (b); i >= (a); --i)
#define log2(x) (31-__builtin_clz(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SZ(x) (int)(x).size()
#define PB push_back
#define FI first
#define SE second
#define mup(x,y) x = min(x,y)
#define Mup(x,y) x = max(x,y)
#define debug(x) cout << #x << " is " << x << el
#define el '\n'
using namespace std; using ll = long long; using ii = pair<int,int>; using iii = tuple<int,int,int>;
void solution(); int main() {ios::sync_with_stdio(0); cin.tie(0); solution();}
const int N = 100003;
int n, h[N];
bool isA[N];
 
void print() {
    vector<int> a, b;
    REP(i, 1, n) {
        if (isA[i])
            a.push_back(h[i]);
        else
            b.push_back(h[i]);
    }
    cout << SZ(a) << el;
    for (auto p : a)
        cout << p << ' ';
    cout << el << SZ(b) << el;
    for (auto p : b)
        cout << p << ' ';
}
 
void input() {
    cin >> n;
    REP(i,1,n) cin >> h[i];
}
void solution() {
    input();
    sort(h+1,h+n+1);
    bool chk;
    //first, A: h[1], h[3],...
    isA[1] = true; chk = true;
    for (int preA = h[1], rA = h[3]-h[1], i = 3; i <= n; ++i) {
        if (h[i] == preA+rA) {
            isA[i] = true;
            preA += rA;
        }
    } int preB = h[2], rB = 1000000; REP(i,4,n) {
        if (!isA[i]) {
            rB = h[i]-preB;
            break;
        }
    } REP(i,4,n) {
        if (!isA[i]) {
            if (h[i] != preB+rB) {chk = false; break;}
            preB += rB;
        }
    }
    if (chk) {print(); return;}
    //second, A: h[1], h[2],...
    fill(isA,isA+n+1,0);
    isA[1] = true; chk = true;
    for (int preA = h[1], rA = h[2]-h[1], i = 2; i <= n; ++i) {
        if (h[i] == preA+rA) {
            isA[i] = true;
            preA += rA;
        }
    } preB = 0, rB = 1000000; int i;
    for(i = 1; i <= n; ++i) if (!isA[i]) {preB = h[i]; break;}
    for (++i; i <= n; ++i) if (!isA[i]) {rB = h[i]-preB; break;}
 
    for (; i <= n; ++i) {
        if (!isA[i]) {
            if (h[i] != preB+rB) {chk = false; break;}
            preB += rB;
        }
    }
    if (chk) {print(); return;}
    cout << -1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3284 KB Output is correct
2 Correct 32 ms 3204 KB Output is correct
3 Correct 36 ms 3272 KB Output is correct
4 Correct 33 ms 3272 KB Output is correct
5 Correct 32 ms 3364 KB Output is correct
6 Correct 32 ms 3236 KB Output is correct
7 Correct 33 ms 3344 KB Output is correct
8 Correct 33 ms 3220 KB Output is correct
9 Incorrect 19 ms 1480 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Halted 0 ms 0 KB -