답안 #793862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793862 2023-07-26T07:38:59 Z Ronin13 곤돌라 (IOI14_gondola) C++17
55 / 100
43 ms 5296 KB
#include "gondola.h"
#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;

int valid(int n, int a[]){
    vector <pii> vv;
    set <int> st;
    for(int i = 0; i < n; i++){
      if(st.find(a[i]) != st.end())
        return 0;
      st.insert(a[i]);
        if(a[i] <= n)
          vv.pb({a[i], i});
    }
    sort(vv.begin(), vv.end());
    for(int i = 1; i < vv.size(); i++){
      int x = vv[i].s, y = vv[i - 1].s;
      int dist = vv[i].f - vv[i - 1].f;
      if((x - y + n) % n != dist)
        return 0;
    }
    return 1;
}

//----------------------

int replacement(int n, int a[], int b[])
{
  int c[n];

  int cur = n + 1;
  int ind = 0;
  vector <pii> vv;
  int x, y;
  for(int i = 0; i < n; i++){
    if(a[i] > n) vv.pb({a[i], i});
    else x = a[i], y = i;
  }
  if(vv.size() == n){
      for(int i = 0; i < n; i++) c[i] = i + 1;
  }
  else{
      for(int i = 0; i < n; i++){
        int dist = (i - y + n) % n;
        c[i] = (x + dist - 1) % n + 1;
      }
  }
  sort(vv.begin(), vv.end());
  for(int i = 0; i < vv.size(); i++){
    while(cur <= vv[i].f)
      b[ind] = c[vv[i].s], c[vv[i].s] = cur, ind++, cur++;
  }
  return ind;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
  return -3;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 1; i < vv.size(); i++){
      |                    ~~^~~~~~~~~~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:47:16: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |   if(vv.size() == n){
      |      ~~~~~~~~~~^~~~
gondola.cpp:57:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   for(int i = 0; i < vv.size(); i++){
      |                  ~~^~~~~~~~~~~
gondola.cpp:42:10: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |   int x, y;
      |          ^
gondola.cpp:53:19: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   53 |         c[i] = (x + dist - 1) % n + 1;
      |                 ~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 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 12 ms 2496 KB Output is correct
7 Correct 7 ms 656 KB Output is correct
8 Correct 28 ms 4636 KB Output is correct
9 Correct 7 ms 1604 KB Output is correct
10 Correct 29 ms 5184 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 14 ms 2428 KB Output is correct
7 Correct 7 ms 612 KB Output is correct
8 Correct 23 ms 4700 KB Output is correct
9 Correct 7 ms 1548 KB Output is correct
10 Correct 29 ms 5112 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 12 ms 2092 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 43 ms 5296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 0 ms 212 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 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 280 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 7 ms 1304 KB Output is correct
12 Correct 8 ms 1492 KB Output is correct
13 Correct 11 ms 1508 KB Output is correct
14 Correct 7 ms 1364 KB Output is correct
15 Correct 16 ms 2380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -