답안 #990649

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990649 2024-05-30T21:56:00 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:10:12: warning: 'min_wa' defined but not used [-Wunused-variable]
   10 | static int min_wa = MAX_K + 1;
      |            ^~~~~~
Anna.cpp:9:18: warning: 'X' defined but not used [-Wunused-variable]
    9 | static long long X;
      |                  ^
Anna.cpp:8:31: warning: 'P' defined but not used [-Wunused-variable]
    8 | static int Q, N, K, A[MAX_N], P[MAX_K];
      |                               ^
Anna.cpp:8:18: warning: 'K' defined but not used [-Wunused-variable]
    8 | static int Q, N, K, A[MAX_N], P[MAX_K];
      |                  ^
Anna.cpp:8:12: warning: 'Q' defined but not used [-Wunused-variable]
    8 | static int Q, N, K, A[MAX_N], P[MAX_K];
      |            ^
/usr/bin/ld: /tmp/ccTi1zaA.o: in function `WrongAnswer(int)':
grader_anna.c:(.text+0x0): multiple definition of `WrongAnswer(int)'; /tmp/ccl6Xi0z.o:Anna.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccTi1zaA.o: in function `Set(int, int)':
grader_anna.c:(.text+0x60): multiple definition of `Set(int, int)'; /tmp/ccl6Xi0z.o:Anna.cpp:(.text+0x30): first defined here
collect2: error: ld returned 1 exit status

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