이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define print(x) cout << x << endl
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
//#define endl '\n'
//#define int long long
using namespace std;
int minimumInstructions(int N, int M, int K, vt<int> C, vt<int> A, vt<vt<int>> B)
{
vt<int> dp(N);
int i = 0;
while(i <= N - M)
{
if (i > 0 && !dp[i - 1])
{
i++;
continue;
}
for(int master = 0; master < M; master++)
{
int m = master;
int j = i;
while(j < N)
{
int tmp = lower_bound(all(B[m]), C[j]) - B[m].begin();
if (B[m][tmp] != C[j]) break;
m = (m + 1) % M;
j++;
}
if (j != i) j--;
//cout << j << endl;
if (j - i + 1 < M)
{
i++;
continue;
}
int tmp = i > 0 ? dp[i - 1] : 0;
dp[j] = !dp[j] ? (j - i + M) / M + tmp : min(dp[j], (j - i + M) / M + tmp);
}
//cout << endl;
i++;
}
//for(int x : dp) cout << x << " ";
//cout << endl;
if (dp[N - 1]) return dp[N - 1];
return -1;
}
/**
main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int ans = minimumInstructions(6, 4, 4, {2, 1, 0, 3, 2, 1}, {3}, {{2}, {1}, {0}, {3}});
print(ans);
}
/**/
컴파일 시 표준 에러 (stderr) 메시지
paint.cpp:69:1: warning: "/*" within comment [-Wcomment]
69 | /**/
|
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |