답안 #223639

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223639 2020-04-15T21:29:12 Z Haunted_Cpp Drvca (COCI19_drvca) C++17
0 / 110
5 ms 640 KB
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
 
#pragma GCC optimize ("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
 
using namespace std;

const int N = 2e3;

int a [N];
bool vis [N];

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) cin >> a[i];
  sort (a, a + n);
  
  for (int i = 0; i < n; i++) {
    vector<int> up = {a[0]}, down;
    if (i) up.emplace_back(a[i]);
    const int diff = a[i] - a[0];
    int nxt = a[i] + (a[i] - a[0]);
    for (int j = 1; j < n; j++) {
      if (j == i) continue;
      if (a[j] == nxt) {
        up.emplace_back(a[j]);
        nxt += diff;
      } else {
        down.emplace_back(a[j]);
      }
    }
    
   
    if ((int) down.size() <= 1) {
      while ((int) down.size() == 0) {
        int l = up.back ();
        up.pop_back ();
        down.emplace_back(l);
      }
      cout << (int) up.size() << '\n';
      for (auto to : up) cout << to << ' ';
      cout << '\n';
      cout << (int) down.size() << '\n';
      for (auto to : down) cout << to << ' ';
      cout << '\n';
      return 0;
    }
    
    const int d = down[1] - down[0];
    for (int j = 1; j < (int) down.size(); j++) {
      if (down[j] - down[j - 1] != d) {
        goto fim;
      }
    }
    
    cout << (int) up.size() << '\n';
    for (auto to : up) cout << to << ' ';
    cout << '\n';
    cout << (int) down.size() << '\n';
    for (auto to : down) cout << to << ' ';
    cout << '\n';
    return 0;
    
    fim:;    
  }
  cout << -1 << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 288 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 432 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Incorrect 5 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 288 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 432 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Incorrect 5 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 288 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 432 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Incorrect 5 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -