답안 #762092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762092 2023-06-20T18:56:15 Z coloboxx 곤돌라 (IOI14_gondola) C++17
20 / 100
14 ms 5220 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))
      //       while (true) {}

      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)
      |           ~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 5 ms 1968 KB Output is correct
7 Correct 12 ms 3272 KB Output is correct
8 Correct 9 ms 3488 KB Output is correct
9 Correct 4 ms 1492 KB Output is correct
10 Correct 11 ms 3852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 5 ms 1888 KB Output is correct
7 Correct 11 ms 3300 KB Output is correct
8 Correct 10 ms 3416 KB Output is correct
9 Correct 4 ms 1492 KB Output is correct
10 Correct 14 ms 3812 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 9 ms 1884 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 14 ms 5220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -