답안 #979575

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

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

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

ll minimumInstructions(ll n, ll m, ll k, ll *c, ll *a, vector<ll> *b)
{
    ll i, j;
    ll dp[n + 5] = {};
    for(i = 0; i <= n - m; ++i)
    {
        for(ll t = 0; t < m && !dp[i]; ++t)
        {
            if(eq(c, i, b, m))
                dp[i] = 1;
            sdvig(b, m);
        }
    }
    ll ans = 1, cur = 0;
    while(cur < n - m)
    {
        ll 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: In function 'long long int minimumInstructions(long long int, long long int, long long int, long long int*, long long int*, std::vector<long long int>*)':
paint.cpp:28:11: warning: unused variable 'j' [-Wunused-variable]
   28 |     ll i, j;
      |           ^
/usr/bin/ld: /tmp/ccEJ4YTi.o: in function `main':
grader.cpp:(.text.startup+0x392): undefined reference to `minimumInstructions(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
collect2: error: ld returned 1 exit status