답안 #980371

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
980371 2024-05-12T06:33:58 Z sleepntsheep 벽 칠하기 (APIO20_paint) C++17
0 / 100
0 ms 348 KB
#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

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);
      |                 ~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -