제출 #774760

#제출 시각아이디문제언어결과실행 시간메모리
774760vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
컴파일 에러
0 ms0 KiB
// #pragma GCC target("abm")
// #pragma GCC optimize("03,unroll-loops")
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("bmi,bmi2,lzcnt,popcnt")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr)

#define put(a) cout << a << "\n"
#define put_2(a, b) cout << a << " " << b << "\n"
#define put_3(a, b, c) cout << a << " " << b << " " << c << "\n"
#define put_4(a, b, c, x) cout << a << " " << b << " " << c << " " << x << "\n"
#define put_5(a, b, c, x, y) cout << a << " " << b << " " << c << " " << x << " " << y << "\n";
#define put_6(a, b, c, x, y, z) cout << a << " " << b << " " << c << " " << x << " " << y << " " << z << "\n";
#define put_fix(a, n) cout << fixed << setprecision(n) << a << "\n"

#define ll long long
#define ldb long double
#define db double

#define sqr(x) (x*x)

#define fto(i, a, b) for (int i = a; i <= b; ++i)
#define fdto(i, b, a) for (int i = b; i >= a; --i)

#define sz(a) (int) (a.size())

#define di deque <int>
#define vi vector <int>
#define vl vector <long long>

#define pii pair <int, int>
#define vii vector <int, int>
#define vpii vector<pair<int, int>>

#define pf push_front
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second

#define oo 1000000007
#define OO 1000000000000000007

#define eps 0.0000000001
#define mod 
#define maxN 200005
#define maxM 10000005

using namespace std;

int n, a[maxN];

void sub_1() {
    for (int i = 2; i <= n; ++i) {
        int pos = 0;
        for (int j = i-1; j >= 1; --j) {
            if (a[j] == a[i]) {
                pos = j;
                break;
            }
        }

        if (pos) {
            for (int j = pos+1; j <= i-1; ++j) a[j] = a[i];
        }
    }

    for (int i = 1; i <= n; ++i) cout << a[i] << "\n";
}

struct data {
    int l, r, val;
};

int mx_pos_val[5];
void sub_2() {
    vector<data> vec;
    mx_pos_val[a[1]] = 1;
    for (int i = 2; i <= n; ++i) {
        if (a[i] == a[mx_pos_val[a[i]]]) {
            vec.push_back({mx_pos_val[a[i]], i, a[i]});
            mx_pos_val[a[i]] = i;
        }
    }

    for (int ivec = 0; ivec < (int) vec.size(); ++ivec) {
        for (int i = vec[ivec].l; i <= vec[ivec].r; ++i) a[i] = vec[ivec].val;
    }

    for (int i = 1; i <= n; ++i) cout << a[i] << "\n";
}

int main () {
    // #ifndef ONLINE_JUDGE
        // freopen("test.inp", "r", stdin);
        // freopen("test.out", "w", stdout);
    // #endif // ONLINE_JUDGE
    FAST;

    cin >> n;
    bool ok_o = false;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i] != 1 && a[2] != 2) ok_o = true;
    }

    if (n <= 10000) sub_1();
    else if (!ok_o) sub_2();

    return 0;
}



















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

Main.cpp: In function 'void sub_2()':
Main.cpp:83:16: error: template argument 1 is invalid
   83 |     vector<data> vec;
      |                ^
Main.cpp:83:16: error: template argument 2 is invalid
Main.cpp:87:17: error: request for member 'push_back' in 'vec', which is of non-class type 'int'
   87 |             vec.push_back({mx_pos_val[a[i]], i, a[i]});
      |                 ^~~~~~~~~
Main.cpp:92:41: error: request for member 'size' in 'vec', which is of non-class type 'int'
   92 |     for (int ivec = 0; ivec < (int) vec.size(); ++ivec) {
      |                                         ^~~~
Main.cpp:93:25: error: invalid types 'int[int]' for array subscript
   93 |         for (int i = vec[ivec].l; i <= vec[ivec].r; ++i) a[i] = vec[ivec].val;
      |                         ^
Main.cpp:93:43: error: invalid types 'int[int]' for array subscript
   93 |         for (int i = vec[ivec].l; i <= vec[ivec].r; ++i) a[i] = vec[ivec].val;
      |                                           ^
Main.cpp:93:68: error: invalid types 'int[int]' for array subscript
   93 |         for (int i = vec[ivec].l; i <= vec[ivec].r; ++i) a[i] = vec[ivec].val;
      |                                                                    ^