Submission #407551

#TimeUsernameProblemLanguageResultExecution timeMemory
407551juggernautPainting Walls (APIO20_paint)C++17
100 / 100
1362 ms14340 KiB
//Solved in the tlx.toki.id copied with so many break lines!!! #include<bits/stdc++.h> #define fr first #define sc second using namespace std; void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} typedef long long ll; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef IOI2021SG #define printl(args...)printf(args) #else #define printl(args...)((void)0) #endif int d[100005]; bool e[100005],f[100005]; vector<int>v[100005]; int minimumInstructions(int n,int m,int k,vector<int>c,vector<int>a,vector<vector<int>>b){ for(int i=0;i<m;i++)for(int j:b[i])v[j].push_back(i); for(int i=0;i<n;i++){ for(int j:v[c[i]]){ if(++d[(j-i%m+m)%m]>=m)e[i]=1; f[(j-i%m+m)%m]=1; } if(i) for(int j:v[c[i-1]])if(!f[(j-i%m+1+m)%m])d[(j-i%m+1+m)%m]=0; for(int j:v[c[i]])f[(j-i%m+m)%m]=0; } int i=n-1,x=0,j; for(;i>=0;x++){ for(j=i;j<i+m&&!e[j];j++); if(j>=i+m)return -1; i=j-m; } return x; }

Compilation message (stderr)

paint.cpp: In function 'void usaco(std::string)':
paint.cpp:10:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
paint.cpp:10:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"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...