Submission #64074

# Submission time Handle Problem Language Result Execution time Memory
64074 2018-08-03T10:10:22 Z Just_Solve_The_Problem Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
436 ms 6636 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int N = (int)1e6 + 7;
const int inf = (int)1e9 + 7;

int n, k;
int a[N];
int cnt[N];

main() {
  scanf("%d %d", &n, &k);
  if (k != 1) return 0;
  int mn = inf;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mn = min(mn, a[i]);
    cnt[a[i]]++;
  }
  int in;
  int cur = -1;
  while (1) {
    if (cnt[mn] & 1) {
      cur = mn;
      break;
    }
    cnt[mn + 1] += cnt[mn] / 2;
    cnt[mn] = 0;
    mn++;
  }
  memset(cnt, sizeof cnt, 0);
  mn = inf;
  for (int i = 1; i <= n; i++) {
    if (a[i] < mn) {
      mn = a[i];
      in = i;
    }
  }
  int l, r;
  l = r = in;
  cnt[a[l]]++;
  mn = inf;
  while (1) {
    while (l > 1 && a[l - 1] == a[r]) {
      l--;
      cnt[a[r]]++;
    }
    while (r < n && a[r + 1] == a[l]) {
      r++;
      cnt[a[l]]++;
    }
//    cout << l << ' ' << r << endl;
    if (cnt[a[l]] & 1) {
      in = l;
      break;
    }
    mn = inf;
    if (l > 1) mn = min(mn, a[l - 1]);
    if (r < n) mn = min(mn, a[r + 1]);
    if (mn == inf) {
      in = 1;
      break;
    }
    if (mn >= cur) {
      in = l;
      break;
    }
    int res = (cnt[a[l]] >> (mn - a[l]));
    cnt[mn] += res;
    if (a[l - 1] == mn) l--;
    if (a[r + 1] == mn) r++;

  }
  for (int i = 1; i <= n; i++) {
    if (i == in) {
      printf("%d ", cur);
    }
    printf("%d ", a[i]);
  }
}

Compilation message

zalmoxis.cpp:14:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:34:28: warning: 'memset' used with constant zero length parameter; this could be due to transposed parameters [-Wmemset-transposed-args]
   memset(cnt, sizeof cnt, 0);
                            ^
zalmoxis.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &k);
   ~~~~~^~~~~~~~~~~~~~~~~
zalmoxis.cpp:44:10: warning: 'in' may be used uninitialized in this function [-Wmaybe-uninitialized]
   cnt[a[l]]++;
       ~~~^
# Verdict Execution time Memory Grader output
1 Incorrect 305 ms 6392 KB not a zalsequence
2 Incorrect 289 ms 6588 KB not a zalsequence
3 Incorrect 300 ms 6588 KB not a zalsequence
4 Incorrect 325 ms 6588 KB not a zalsequence
5 Incorrect 408 ms 6588 KB not a zalsequence
6 Incorrect 436 ms 6636 KB not a zalsequence
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6636 KB Unexpected end of file - int32 expected
2 Incorrect 3 ms 6636 KB Unexpected end of file - int32 expected
3 Incorrect 3 ms 6636 KB Unexpected end of file - int32 expected
4 Incorrect 4 ms 6636 KB Unexpected end of file - int32 expected
5 Incorrect 3 ms 6636 KB Unexpected end of file - int32 expected
6 Incorrect 4 ms 6636 KB Unexpected end of file - int32 expected
7 Incorrect 3 ms 6636 KB Unexpected end of file - int32 expected
8 Incorrect 2 ms 6636 KB Unexpected end of file - int32 expected
9 Incorrect 2 ms 6636 KB Unexpected end of file - int32 expected
10 Incorrect 3 ms 6636 KB Unexpected end of file - int32 expected
11 Incorrect 2 ms 6636 KB Unexpected end of file - int32 expected
12 Incorrect 4 ms 6636 KB Unexpected end of file - int32 expected
13 Incorrect 3 ms 6636 KB Unexpected end of file - int32 expected
14 Incorrect 2 ms 6636 KB Unexpected end of file - int32 expected