Submission #762089

# Submission time Handle Problem Language Result Execution time Memory
762089 2023-06-20T18:48:57 Z coloboxx Gondola (IOI14_gondola) C++17
20 / 100
15 ms 5860 KB
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx,avx2,sse2,sse3,ssse3,sse4,lzcnt,popcnt")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#define ll long long
#define point pair<int, int>
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define show(x) cerr << (#x) << " = " << x << '\n'
#define print(x) if (1) {cerr << (#x) << " = "; for (auto it : x) \
      cerr << it << ' '; cerr << '\n';}
#define fast_io ios_base::sync_with_stdio(0), cin.tie(0)
 
const int N = 1 << 19;
const int S = 1e7 + 64;
const int INF = 2e9 + 64;
const ll MAX = 2e18 + 64;
const int LOG = 21;
const int MOD = 1e9 + 7; //998244353;
const int P = 79;
 
using namespace std;

#include "gondola.h"

int f = -1;

int valid(int n, int a[]) {
      unordered_set<int> st;

      for (int i = 0; i < n; ++i)
            st.insert(a[i]);

      for (int i = 0; i < n; ++i) {
            if (a[i] <= n) {
                  f = (n - a[i] % n + 1) % n;
                  break; 
            }
      }

      if (st.size() < n)
            return 0;

      if (f == -1)
            return 1;

      for (int i = 0; i < n; ++i)
            if (a[i] <= n && a[i] != (i - f + n) % n + 1)
                  return 0;

      return 1;
}

int replacement(int n, int a[], int res[]) {
      if (!valid(n, a))
            return 0;

      if (f == -1)
            f = 0;

      vector<int> ans(N);
      for (int i = 0; i < n; ++i)
            if (a[i] > n)
                  ans[a[i]] = (i - f + n) % n + 1;

      int len = 0;
      for (int i = 0; i < N; ++i)
            if (ans[i]) res[len] = ans[i], ++len;
      return len;
}

int countReplacement(int n, int a[]) {
      return 0;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:46:21: warning: comparison of integer expressions of different signedness: 'std::unordered_set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |       if (st.size() < n)
      |           ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 6 ms 2096 KB Output is correct
7 Correct 13 ms 3812 KB Output is correct
8 Correct 10 ms 3792 KB Output is correct
9 Correct 4 ms 1600 KB Output is correct
10 Correct 11 ms 4392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 308 KB Output is correct
6 Correct 5 ms 2096 KB Output is correct
7 Correct 12 ms 3832 KB Output is correct
8 Correct 10 ms 3784 KB Output is correct
9 Correct 4 ms 1600 KB Output is correct
10 Correct 11 ms 4324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 6 ms 2096 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 15 ms 5860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2260 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2356 KB Output is correct
2 Incorrect 1 ms 308 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2352 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -