답안 #954901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954901 2024-03-28T19:19:14 Z Lemser Broken Device (JOI17_broken_device) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "Annalib.h"
#define endl '\n'
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define fore(i,l,r) for(int i=l;i<r;i++)
#define fo(i,n) fore(i,0,n)
#define forex(i,r,l) for(int i=r;i>=l;i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define ll long long
using namespace std;
using vi = vector<int>;using ii = pair<int,int>;
ll A[160];
void Set(int idx, int bit ){
	A[idx] = bit;
}
string desc(long long X)
{
  string resp;
  while (X)
  {
    ll mod = X % 2ll;
 
    if (mod == 1)
    {
        resp += "1";
    }else
    {
        resp += "0";
    }
    
    X /= 2;
  }
 
  while (resp.size() < 60)
  {
    resp += "0";
  }
  
 
  reverse(resp.begin(), resp.end());
  resp += resp;
 
  return resp;
  
}
 
void Anna( int N, long long X, int K, int P[] )
{
  string num = desc(X);
  for( int i = 0; i < 120; i++ )
  {
    int bit = num[i] - '0';
    Set(i, bit);
  }
 
  int wrongPos = P[0];
  if (wrongPos < 120)
  {
   wrongPos = 59 - wrongPos;
    int r = num[wrongPos] - '0';
 
    Set(120, r);
  }else
  {
    Set(120, 1);
  }
  
 
  for (int i = 121; i < N; i++)
  {
    Set(i, 1);
  }
 
 
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
 
long long comp(string s)
{
    reverse(s.begin(), s.end());
 
    long long resp = 0;
 
    long long p2 = 1;
 
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '1')
        {
            resp += p2;
        }
 
        p2 *= 2;
 
    }
  
  return resp;
  
}
 
long long Bruno( int N, int A[] )
{
  
  string resp;
 
  for (int i = 0; i < 60; i++)
  {
    if (A[i] == A[i + 60])
    {
      resp += A[i] +'0';
    }else
    {
      resp += A[120] + '0';
    }
    
  }
 
  long long X = comp(resp);
  
 
  return X;
}

Compilation message

/usr/bin/ld: /tmp/ccjTUkyg.o: in function `Set(int, int)':
grader_anna.c:(.text+0x60): multiple definition of `Set(int, int)'; /tmp/cceWgV6g.o:Anna.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status

Bruno.cpp: In function 'long long int comp(std::string)':
Bruno.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 0; i < s.size(); i++)
      |                     ~~^~~~~~~~~~