답안 #397324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397324 2021-05-01T22:25:30 Z rocks03 벽 칠하기 (APIO20_paint) C++14
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B){
    vector<pii> v;
    rep(x, 0, M){
        rep(y, 0, N - M + 1){
            bool ok = true;
            rep(l, 0, M){
                int i = (x + l) % M, j = y + l;
                auto it = lower_bound(all(B[i]), C[j]);
                if(it != B[i].end() && *it == C[j]) continue;
                ok = false; break;
            }
            if(ok) v.pb({y, y + M});
        }
    }
    sort(all(v));
    vector<int> dp(SZ(v), INT_MAX);
    rep(i, 0, SZ(v)){
        auto [l, r] = v[i];
        if(l == 0) dp[i] = 1;
    }
    rep(i, 0, SZ(v)){
        auto [l, r] = v[i];
        rep(j, i + 1, SZ(v)){
            auto [ql, qr] = v[j];
            if(ql <= r && qr >= r){
                dp[j] = min(dp[j], dp[i] + 1);
            }
        }
    }
    int ans = INT_MAX;
    rep(i, 0, SZ(v)){
        auto [l, r] = v[i];
        if(r == N - 1) ans = min(ans, dp[i]);
    }
    if(ans == INT_MAX) ans = -1;
    return ans;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:34:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |         auto [l, r] = v[i];
      |              ^
paint.cpp:38:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   38 |         auto [l, r] = v[i];
      |              ^
paint.cpp:40:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   40 |             auto [ql, qr] = v[j];
      |                  ^
paint.cpp:48:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   48 |         auto [l, r] = v[i];
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -