# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1193533 | cpdreamer | Painting Walls (APIO20_paint) | C++20 | 1595 ms | 9028 KiB |
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll MOD=998244353;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,greater<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
void file(){
freopen("input.txt.txt","r",stdin);
freopen("output.txt.txt","w",stdout);
}
#define V vector
#define pb push_back
#define P pair
#define S second
#define F first
#define all(v) v.begin(),v.end()
int minimumInstructions(
int N, int M, int K, std::vector<int> C,
std::vector<int> A, std::vector<std::vector<int>> B) {
ll dp[N];
for(int i=0;i<N;i++){
dp[i]=1e15;
}
V<set<int>>b(M);
map<P<int,int>,int>mp;
for(int i=0;i<M;i++){
for(auto u:B[i]){
b[i].insert(u);
}
}
for(int i=0;i<M;i++){
bool ch[N];
for(int j=0;j<N;j++){
int id=((j%M)+i)%M;
if(b[id].count(C[j])){
ch[j]=true;
}
else
ch[j]=false;
}
int c=0;
for(int j=0;j<N;j++){
if(!ch[j]){
c=0;
}
else{
c++;
if(c>=M){
mp[{j,j-M+1}]=1;
}
}
}
}
if(M==1 && mp[{0,0}]){
dp[0]=1;
}
for(int i=1;i<N;i++){
ll v=1e15;
for(int j=i-1;j>=max(i-M,0);j--){
v=min(v,dp[j]);
if(j==i-M)continue;
}
bool f=false;
if(mp[{i,i-M+1}]){
f=true;
}
if(f){
if(i==M-1)v=0;
dp[i]=v+1;
}
}
if(dp[N-1]>=(ll)1e15)
return -1;
return (int)dp[N-1];
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |