답안 #850116

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850116 2023-09-15T18:57:07 Z tvladm2009 벽 칠하기 (APIO20_paint) C++17
컴파일 오류
0 ms 0 KB
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
        vector<int> a, c;
        vector<vector<int>> b;

        n = N;
        m = M;
        k = K;
        c = C;
        a = A;
        b = B;
        assert((int)c.size() == n);
        assert((int)a.size() == m);
        assert((int)b.size() == m);
        for (int i = 0; i < m; i++) {
                assert((int)b[i].size() == a[i]);
        }

        vector<int> f(n, 0);
        for (int i = 0; i < m; i++) {
                for (auto& it : b[i]) {
                        f[it]++;
                }
        }
        vector<int> has(k, -1);
        vector<int> need(n, 0);
        for (int i = 0; i < n; i++) {
                for (int i = 0; i < m; i++) {
                        for (auto& it : b[i]) {
                                has[it] = i;
                        }
                }
        }

        for (int i = 0; i < n; i++) {
                if (f[c[i]] == 0) {
                        return -1;
                }
                need[i] = has[c[i]];
        }
        int want = need[0];
        int cur = 1;
        for (int i = 1; i < n; i++) {
                want++;
                want %= m;
                if (need[i] != want) {
                        cur++;
                        want = need[i];
                }
        }
        return sol;
}

Compilation message

paint.cpp:2:46: error: 'vector' has not been declared
    2 | int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
      |                                              ^~~~~~
paint.cpp:2:52: error: expected ',' or '...' before '<' token
    2 | int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
      |                                                    ^
paint.cpp: In function 'int minimumInstructions(int, int, int, int)':
paint.cpp:3:9: error: 'vector' was not declared in this scope
    3 |         vector<int> a, c;
      |         ^~~~~~
paint.cpp:3:16: error: expected primary-expression before 'int'
    3 |         vector<int> a, c;
      |                ^~~
paint.cpp:4:23: error: expected primary-expression before 'int'
    4 |         vector<vector<int>> b;
      |                       ^~~
paint.cpp:6:9: error: 'n' was not declared in this scope
    6 |         n = N;
      |         ^
paint.cpp:7:9: error: 'm' was not declared in this scope
    7 |         m = M;
      |         ^
paint.cpp:8:9: error: 'k' was not declared in this scope
    8 |         k = K;
      |         ^
paint.cpp:9:9: error: 'c' was not declared in this scope
    9 |         c = C;
      |         ^
paint.cpp:9:13: error: 'C' was not declared in this scope
    9 |         c = C;
      |             ^
paint.cpp:10:9: error: 'a' was not declared in this scope
   10 |         a = A;
      |         ^
paint.cpp:10:13: error: 'A' was not declared in this scope
   10 |         a = A;
      |             ^
paint.cpp:11:9: error: 'b' was not declared in this scope
   11 |         b = B;
      |         ^
paint.cpp:11:13: error: 'B' was not declared in this scope
   11 |         b = B;
      |             ^
paint.cpp:12:9: error: 'assert' was not declared in this scope
   12 |         assert((int)c.size() == n);
      |         ^~~~~~
paint.cpp:1:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
  +++ |+#include <cassert>
    1 | 
paint.cpp:19:16: error: expected primary-expression before 'int'
   19 |         vector<int> f(n, 0);
      |                ^~~
paint.cpp:22:25: error: 'f' was not declared in this scope
   22 |                         f[it]++;
      |                         ^
paint.cpp:25:16: error: expected primary-expression before 'int'
   25 |         vector<int> has(k, -1);
      |                ^~~
paint.cpp:26:16: error: expected primary-expression before 'int'
   26 |         vector<int> need(n, 0);
      |                ^~~
paint.cpp:30:33: error: 'has' was not declared in this scope
   30 |                                 has[it] = i;
      |                                 ^~~
paint.cpp:36:21: error: 'f' was not declared in this scope
   36 |                 if (f[c[i]] == 0) {
      |                     ^
paint.cpp:39:17: error: 'need' was not declared in this scope
   39 |                 need[i] = has[c[i]];
      |                 ^~~~
paint.cpp:39:27: error: 'has' was not declared in this scope
   39 |                 need[i] = has[c[i]];
      |                           ^~~
paint.cpp:41:20: error: 'need' was not declared in this scope
   41 |         int want = need[0];
      |                    ^~~~
paint.cpp:51:16: error: 'sol' was not declared in this scope
   51 |         return sol;
      |                ^~~