답안 #979595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979595 2024-05-11T08:03:32 Z vjudge1 벽 칠하기 (APIO20_paint) C++17
컴파일 오류
0 ms 0 KB
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int eq(int c[], int p, vector<ll> b[], int m)
{
    int ok = 1;
    for(int i = p; i < p + m; ++i)
    {
        int _ok = 0;
        for(int j : b[i - p])
            _ok |= c[i] == j;
        ok &= _ok;
    }
    return ok;
}

void sdvig(vector<int> b[], int m)
{
    for(int i = 0; i < m - 1; ++i)
        swap(b[i], b[i + 1]);
}

int minimumInstructions(int n, int m, int k, int c[], int a[], vector<int> b[])
{
    int i;
    int dp[n + 5] = {};
    for(i = 0; i <= n - m; ++i)
    {
        for(int t = 0; t < m && !dp[i]; ++t)
        {
            if(eq(c, i, b, m))
                dp[i] = 1;
            sdvig(b, m);
        }
    }
    int ans = 1, cur = 0;
    while(cur < n - m)
    {
        int lst = INF;
        for(i = cur + 1; i <= cur + m; ++i)
            if(dp[i])
                lst = i;
        cur = lst;
        ++ans;
    }
//    for(i = 0; i < n; ++i)
//        cout << dp[i] << ' ';
//    return;
    return (cur < INF ? ans : -1);
}

//int main()
//{
////    ios_base::sync_with_stdio(0);
////    cin.tie(0), cout.tie(0);
////    solve();
//}

//8 3 5
//3 3 1 3 4 4 2 2
//3 0 1 2
//2 2 3
//2 3 4

Compilation message

paint.cpp:6:31: error: 'll' was not declared in this scope
    6 | int eq(int c[], int p, vector<ll> b[], int m)
      |                               ^~
paint.cpp:6:33: error: template argument 1 is invalid
    6 | int eq(int c[], int p, vector<ll> b[], int m)
      |                                 ^
paint.cpp:6:33: error: template argument 2 is invalid
paint.cpp: In function 'int eq(int*, int, int*, int)':
paint.cpp:12:28: error: 'begin' was not declared in this scope
   12 |         for(int j : b[i - p])
      |                            ^
paint.cpp:12:28: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from paint.cpp:2:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from paint.cpp:2:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
paint.cpp:12:28: error: 'end' was not declared in this scope
   12 |         for(int j : b[i - p])
      |                            ^
paint.cpp:12:28: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from paint.cpp:2:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from paint.cpp:2:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
paint.cpp: In function 'int minimumInstructions(int, int, int, int*, int*, std::vector<int>*)':
paint.cpp:33:25: error: cannot convert 'std::vector<int>*' to 'int*'
   33 |             if(eq(c, i, b, m))
      |                         ^
      |                         |
      |                         std::vector<int>*
paint.cpp:6:35: note:   initializing argument 3 of 'int eq(int*, int, int*, int)'
    6 | int eq(int c[], int p, vector<ll> b[], int m)
      |                        ~~~~~~~~~~~^~~