제출 #374610

#제출 시각아이디문제언어결과실행 시간메모리
374610vishesh312곤돌라 (IOI14_gondola)C++17
컴파일 에러
0 ms0 KiB
include "bits/stdc++.h"
using namespace std;
#include "gondola.h"

int valid(int n, int arr[]) {
    map<int, bool> mp;
    vector<int> v(arr, arr+n);
    auto it = min_element(v.begin(), v.end());
    rotate(v.begin(), it, v.end());
    for (int i = 0; i < n; ++i) {
        if (mp[v[i]]) return 0;
        mp[v[i]] = true;
        if (v[i] <= n and i != v[i] - v[0]) return 0;
    }
    return 1;
}

int replacement(int n, int a[], int b[]) {
    vector<int> v(a, a+n);
    auto it = min_element(v.begin(), v.end());
    int mn = *it, pos = it - v.begin(), mx = *max_element(v.begin(), v.end());
    rotate(v.begin(), v.begin() + (pos - mn%n + 1 + n) % n, v.end());
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        mp[v[i]] = i+1;
    }
    for (int i = n+1; i <= mx; ++i) {
        if (mp.count(i)) b[i-n-1] = mp[i];
        else {
            b[i-n-1] = mp[mx];
            mp[mx] = i;
        }
    }
    return mx - n;
}

using ll = long long;
const ll mod = 1e9+9;
#define sz(x) (int)x.size()

ll binexp(ll a, ll b) {
    a %= mod;
    ll ret = 1;
    while (b) {
        if (b&1) {
            ret = (ret * a) % mod;
        }
        a = (a * a) % mod;
        b >>= 1;
    }
    return ret;
}

int countReplacement(int n, int a[]) {
    vector<int> v(a, a+n);
    auto it = min_element(v.begin(), v.end());
    rotate(v.begin(), it, v.end());
    vector<int> v2 = v;
    sort(v2.begin(), v2.end());
    if (unique(v2.begin(), v2.end()) != v2.end()) return 0;
    for (int i = 0; i < n; ++i) {
        if (v[i] <= n and i != v[i] - v[0]) return 0;
    }
    ll ans;
    if (v2[0] > n) ans = n;
    else ans = 1;
    vector<int> bigger;
    bigger.push_back(n);
    for (int i = 0; i < n; ++i) if (v[i] > n) bigger.push_back(v[i]);
    sort(bigger.begin(), bigger.end());
    for (int i = 1; i < sz(bigger); ++i) {
        ans = (ans * binexp(sz(bigger) - i, bigger[i] - bigger[i-1] - 1)) % mod;
    }
    int ret = ans;
    return ret;
}

컴파일 시 표준 에러 (stderr) 메시지

gondola.cpp:1:1: error: 'include' does not name a type
    1 | include "bits/stdc++.h"
      | ^~~~~~~
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:6:5: error: 'map' was not declared in this scope
    6 |     map<int, bool> mp;
      |     ^~~
gondola.cpp:6:9: error: expected primary-expression before 'int'
    6 |     map<int, bool> mp;
      |         ^~~
gondola.cpp:7:5: error: 'vector' was not declared in this scope
    7 |     vector<int> v(arr, arr+n);
      |     ^~~~~~
gondola.cpp:7:12: error: expected primary-expression before 'int'
    7 |     vector<int> v(arr, arr+n);
      |            ^~~
gondola.cpp:8:27: error: 'v' was not declared in this scope
    8 |     auto it = min_element(v.begin(), v.end());
      |                           ^
gondola.cpp:8:15: error: 'min_element' was not declared in this scope
    8 |     auto it = min_element(v.begin(), v.end());
      |               ^~~~~~~~~~~
gondola.cpp:9:5: error: 'rotate' was not declared in this scope
    9 |     rotate(v.begin(), it, v.end());
      |     ^~~~~~
gondola.cpp:11:13: error: 'mp' was not declared in this scope
   11 |         if (mp[v[i]]) return 0;
      |             ^~
gondola.cpp:12:9: error: 'mp' was not declared in this scope
   12 |         mp[v[i]] = true;
      |         ^~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:19:5: error: 'vector' was not declared in this scope
   19 |     vector<int> v(a, a+n);
      |     ^~~~~~
gondola.cpp:19:12: error: expected primary-expression before 'int'
   19 |     vector<int> v(a, a+n);
      |            ^~~
gondola.cpp:20:27: error: 'v' was not declared in this scope
   20 |     auto it = min_element(v.begin(), v.end());
      |                           ^
gondola.cpp:20:15: error: 'min_element' was not declared in this scope
   20 |     auto it = min_element(v.begin(), v.end());
      |               ^~~~~~~~~~~
gondola.cpp:22:36: error: 'pos' was not declared in this scope
   22 |     rotate(v.begin(), v.begin() + (pos - mn%n + 1 + n) % n, v.end());
      |                                    ^~~
gondola.cpp:22:5: error: 'rotate' was not declared in this scope
   22 |     rotate(v.begin(), v.begin() + (pos - mn%n + 1 + n) % n, v.end());
      |     ^~~~~~
gondola.cpp:23:5: error: 'map' was not declared in this scope
   23 |     map<int, int> mp;
      |     ^~~
gondola.cpp:23:9: error: expected primary-expression before 'int'
   23 |     map<int, int> mp;
      |         ^~~
gondola.cpp:25:9: error: 'mp' was not declared in this scope; did you mean 'mn'?
   25 |         mp[v[i]] = i+1;
      |         ^~
      |         mn
gondola.cpp:27:28: error: 'mx' was not declared in this scope; did you mean 'mn'?
   27 |     for (int i = n+1; i <= mx; ++i) {
      |                            ^~
      |                            mn
gondola.cpp:28:13: error: 'mp' was not declared in this scope; did you mean 'mn'?
   28 |         if (mp.count(i)) b[i-n-1] = mp[i];
      |             ^~
      |             mn
gondola.cpp:34:12: error: 'mx' was not declared in this scope; did you mean 'mn'?
   34 |     return mx - n;
      |            ^~
      |            mn
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:55:5: error: 'vector' was not declared in this scope
   55 |     vector<int> v(a, a+n);
      |     ^~~~~~
gondola.cpp:55:12: error: expected primary-expression before 'int'
   55 |     vector<int> v(a, a+n);
      |            ^~~
gondola.cpp:56:27: error: 'v' was not declared in this scope
   56 |     auto it = min_element(v.begin(), v.end());
      |                           ^
gondola.cpp:56:15: error: 'min_element' was not declared in this scope
   56 |     auto it = min_element(v.begin(), v.end());
      |               ^~~~~~~~~~~
gondola.cpp:57:5: error: 'rotate' was not declared in this scope
   57 |     rotate(v.begin(), it, v.end());
      |     ^~~~~~
gondola.cpp:58:12: error: expected primary-expression before 'int'
   58 |     vector<int> v2 = v;
      |            ^~~
gondola.cpp:59:10: error: 'v2' was not declared in this scope
   59 |     sort(v2.begin(), v2.end());
      |          ^~
gondola.cpp:59:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   59 |     sort(v2.begin(), v2.end());
      |     ^~~~
      |     short
gondola.cpp:60:9: error: 'unique' was not declared in this scope
   60 |     if (unique(v2.begin(), v2.end()) != v2.end()) return 0;
      |         ^~~~~~
gondola.cpp:67:12: error: expected primary-expression before 'int'
   67 |     vector<int> bigger;
      |            ^~~
gondola.cpp:68:5: error: 'bigger' was not declared in this scope
   68 |     bigger.push_back(n);
      |     ^~~~~~