Submission #980371

#TimeUsernameProblemLanguageResultExecution timeMemory
980371sleepntsheepPainting Walls (APIO20_paint)C++17
0 / 100
0 ms348 KiB
#include "paint.h" #include<stdlib.h> #include <vector> /* * * * * */ #define NN 100000 #define MM 50000 #define KK 100000 void push(int**eh,int*eo,int i,int j) { int o=eo[i]++; if(!o)eh[i]=(int*)malloc(2*sizeof**eh); else if(!(o&o-1))eh[i]=(int*)realloc(eh[i],2*o*sizeof**eh); eh[i][o]=j; } int*eh[MM], eo[MM]; int*fh[KK],fo[KK]; int freq[NN]; int minimumInstructions( int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { for(int i=0;i<N;++i)push(fh,fo,C[i],i); for(int i=0;i<M;++i) for(int j=0;j<A[i];++j) for(int k=0;k<fo[B[i][j]];++j) if(!freq[fh[B[i][j]][k]]++) push(eh,eo,i,fh[B[i][j]][k]); // should not push more than O(400000) return 0; }

Compilation message (stderr)

paint.cpp: In function 'void push(int**, int*, int, int)':
paint.cpp:21:18: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   21 |     else if(!(o&o-1))eh[i]=(int*)realloc(eh[i],2*o*sizeof**eh);
      |                 ~^~
#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...