답안 #595766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595766 2022-07-14T06:18:08 Z maomao90 기억 압축 (JOI15_memory) C++17
컴파일 오류
0 ms 0 KB
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;

#define REP(i, j, k) for (int i = j; i < k; i++)
#define RREP(i, j, k) for (int i = j; i >= k; i--)

template <class T>
bool inline mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
bool inline mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef tuple<int, int, int> iii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int MAXN = 100;
const int INF = 1000000005;
const ll LINF = 1000000000000000005;

inline isop(char c) {
    return c == '(' || c == '<';
}
inline int getno(char c) {
    if (c == '(' || c == ')') {
        return 1;
    } else {
        return 2;
    }
}
inline vi itov(int m) {
    vi res(4, 0);
    res[0] = m % MAXN;
    m /= MAXN;
    res[1] = m % MAXN;
    m /= MAXN;
    res[2] = m % MAXN;
    m /= MAXN;
    res[3] = m;
    return res;
}
inline int vtoi(vi v) {
    int res = 0;
    RREP (i, 3, 0) {
        res *= MAXN;
        res += v[i];
    }
    return res;
}

int Memory(int n, int m) {
    vi cur = itov(m);
    char c = Get(cur[1] + 1);
    if (cur[2] == cur[0] && isop(c)) {
        if (cur[3] != 0) {
            return -2;
        }
        cur[3] = getno(c);
    } else if (cur[2] - 1 == cur[0] && !isop(c)) {
        if (cur[3] != getno(c)) {
            return -2;
        }
        cur[3] = 0;
    }
    cur[2] += isop(c) ? 1 : -1;
    if (cur[2] < 0) {
        return -2;
    }
    if (cur[1] < n - 1) {
        cur[1]++;
    } else {
        if (cur[2] != 0) {
            return -2;
        }
        if (cur[0] == n - 1) {
            return -1;
        }
        cur[0]++;
        cur[1] = 0;
        cur[2] = 0;
        cur[3] = 0;
    }
    return vtoi(cur);
}

Compilation message

memory.cpp:34:8: error: ISO C++ forbids declaration of 'isop' with no type [-fpermissive]
   34 | inline isop(char c) {
      |        ^~~~