# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1193518 | cpdreamer | Painting Walls (APIO20_paint) | C++20 | 1563 ms | 21592 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()
bool check(V<int>a,V<set<int>>b,int id){
if(a.size()!=b.size())return false;
int n=(int)a.size();
bool f=true;
for(int j=id,cnt=0;cnt<n;j++,cnt++){
if(b[j%n].count(a[cnt])==0)f=false;
}
if(f)return true;
return false;
}
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<int,V<int>>mp;
for(int i=0;i<M;i++){
for(auto u:B[i]){
b[i].insert(u);
mp[u].pb(i);
}
}
if(M==1 && check({C[0]},b,0)){
dp[0]=1;
}
for(int i=1;i<N;i++){
ll v=1e15;
V<int>a;
a.pb(C[i]);
for(int j=i-1;j>=max(i-M,0);j--){
v=min(v,dp[j]);
if(j==i-M)continue;
a.pb(C[j]);
}
reverse(all(a));
bool f=false;
if(i>=M-1) {
for (auto u: mp[C[i-M+1]]) {
if (check(a, b, u))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... |