Submission #1193536

#TimeUsernameProblemLanguageResultExecution timeMemory
1193536cpdreamerPainting Walls (APIO20_paint)C++20
28 / 100
399 ms40312 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 b[2001][20001]; 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; } for(int i=0;i<M;i++){ for(int j=0;j<K;j++){ b[i][j]=false; } } bool good[N]; memset(good,false,sizeof(good)); for(int i=0;i<M;i++){ for(auto u:B[i]){ b[i][u]=true; } } 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][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){ good[j]=true; } } } } if(M==1 && good[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(good[i]){ 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]; }

Compilation message (stderr)

paint.cpp: In function 'void file()':
paint.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen("input.txt.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
paint.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen("output.txt.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...