답안 #990647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990647 2024-05-30T21:55:36 Z MarwenElarbi Broken Device (JOI17_broken_device) C++17
컴파일 오류
0 ms 0 KB
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
/*#define MAX_K 40
#define MAX_N 150

static int Q, N, K, A[MAX_N], P[MAX_K];
static long long X;
static int min_wa = MAX_K + 1;

void WrongAnswer( int e ){
  fprintf( stderr, "Wrong Answer [%d]\n", e );
  exit( 0 );
}

void Set( int pos, int bit ){
  if( !( 0 <= pos && pos < N ) ){
    WrongAnswer( 1 );
  }
  if( A[pos] != -1 ){
    WrongAnswer( 2 );
  }
  if( !( bit == 0 || bit == 1 ) ){
    WrongAnswer( 3 );
  }
  A[pos] = bit;
}*/
void Anna( int N, long long X, int K, int P[] ){
    int tab[N];
    memset(tab,0,sizeof tab);
    for (int i = 0; i < K; ++i)
    {
        tab[P[i]]=-1;
    }
    int convert[65];
    for (int i = 0; i < 64; ++i)
    {
        convert[i]=((1<<i)&X)>0;
        //cout <<convert[i]<<" ";
    }//cout <<endl;
    int lst=0;
    for (int i = 0; i < N-1; ++i)
    {
        if(tab[i]!=-1&&tab[i+1]!=-1){
            tab[i]=(convert[lst]==1);
            tab[i+1]=1;
            lst++;
            i+=2;
        }
    }
    for (int i = 0; i < N; ++i)
    {
        //cout <<tab[i]<<" ";
        if(tab[i]==1) Set(i,1);
        else Set(i,0);
    }//cout <<endl;
}
long long Bruno( int N, int A[] ){
    int lst=0;
    long long x=0;
    for (int i = 0; i < N-2; ++i)
    {
        if(A[i+1]==1&&A[i+2]!=1){
            if(A[i]==1) x+=(1<<lst);
            lst++;
        }
    }
    if(A[N-1]==1&&A[N-2]==1) x+=(1<<lst);
    //cout <<x<<endl;
    return x;
}
/*int main( int argc, char** argv ){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
  int i, query_cnt;
  long long ans;

  scanf( "%d", &Q );
  
  for( query_cnt = 0; query_cnt < Q; query_cnt++ ){
    scanf( "%d %lld %d", &N, &X, &K );
    for( i = 0; i < K; i++ ){
      scanf( "%d", &P[i] );
    }

    for( i = 0; i < N; i++ ){
      A[i] = -1;
    }
    
    Anna( N, X, K, P );

    for( i = 0; i < N; i++ ){
      if( A[i] == -1 ){
        WrongAnswer( 4 );
      }
    }

    for( i = 0; i < K; i++ ){
      A[ P[i] ] = 0;
    }
        
    ans = Bruno( N, A );
    
    if( ans != X ){
      if( K < min_wa ){
        min_wa = K;
      }
    }
  }

  if( min_wa == 1 ){
    if( K < min_wa ){
      min_wa = K;
    }
  }

  fprintf( stderr, "Accepted\n" );
  fprintf( stderr, "L* = %d\n", min_wa - 1 );
  
  return 0;
}*/



    

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:55:23: error: 'Set' was not declared in this scope
   55 |         if(tab[i]==1) Set(i,1);
      |                       ^~~
Anna.cpp:56:14: error: 'Set' was not declared in this scope
   56 |         else Set(i,0);
      |              ^~~

/usr/bin/ld: /tmp/ccWidU6U.o: in function `main':
grader_bruno.cpp:(.text.startup+0x13d): undefined reference to `Bruno(int, int*)'
collect2: error: ld returned 1 exit status