답안 #1078446

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078446 2024-08-27T17:31:25 Z anton Broken Device (JOI17_broken_device) C++17
85 / 100
41 ms 2640 KB
#include "Annalib.h"
#include<bits/stdc++.h>

using namespace std;
#define ll long long 

int N;
ll X;

void Anna( int _N, long long _X, int K, int P[] ){
  N = _N;
  X = _X;
  

  vector<int> base3;
  while(X>0){
    base3.push_back(X%3LL);
    X/=3LL;
  }


  vector<bool> broken(N, false);
  for(int i = 0; i<K; i++){
    broken[P[i]] = true;
  }

  vector<int> res(N);
  auto mySet = [&](int pos, int val){
    if(pos<N){
      res[pos] = val;
    }
  };

  vector<int> info_bits;
  for(auto e: base3){
    if(e==0){
      info_bits.push_back(0);
      info_bits.push_back(1);
    }
    else if(e==1){
      info_bits.push_back(1);
      info_bits.push_back(0);
    }
    else if(e==2){
      info_bits.push_back(1);
      info_bits.push_back(1);
    }
  }
  /*for(auto e: info_bits){
    cout<<e<<" ";
  }
  cout<<endl;*/

  int cur_pos = 0;
  int cur_bit =0;
  while(cur_pos<N && cur_bit<info_bits.size()){
    if(!info_bits[cur_bit] || !broken[cur_pos]){
      if(!info_bits[cur_bit+1] || !broken[cur_pos+1]){
        res[cur_pos] =info_bits[cur_bit];
        res[cur_pos+1] = info_bits[cur_bit+1];
        cur_bit+=2;
      }
    }
    cur_pos+=2;
  }

  

  for(int i = 0; i<N; i++){
    Set(i, res[i]);
    if(!broken[i]){
    }
  }
  

}
#include "Brunolib.h"
#include<bits/stdc++.h>

using namespace std;
#define ll long long 

long long Bruno( int N, int A[] ){
  vector<ll> bits;
  for(int i = 0; i<N; i+=2){
    if(A[i]>0 || A[i+1]>0){
      bits.push_back(A[i]);
      bits.push_back(A[i+1]);
    }
  }
  ll res= 0;

  /*for(auto e: bits){
    cout<<e<<" ";
  }
  cout<<endl;*/
  vector<int> base3;


  for(int i = 0; i<bits.size(); i+=2){
    if(bits[i] == 0 && bits[i+1] == 0){
    
    }
    else{
      if(bits[i] == 0 && bits[i+1] == 1){
        base3.push_back(0);
      }
      if(bits[i] == 1&& bits[i+1] == 0){
        base3.push_back(1);
      }
      if(bits[i] == 1 && bits[i+1] == 1){
        base3.push_back(2);
      }
    }
  }

  ll X= 0;

  while(base3.size()>0){
    X*=3LL;
    X += (ll)(base3.back());
    base3.pop_back();
  }
  //cout<<X<<endl;
  return X;

}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:56:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   while(cur_pos<N && cur_bit<info_bits.size()){
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~
Anna.cpp:28:8: warning: variable 'mySet' set but not used [-Wunused-but-set-variable]
   28 |   auto mySet = [&](int pos, int val){
      |        ^~~~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int i = 0; i<bits.size(); i+=2){
      |                  ~^~~~~~~~~~~~
Bruno.cpp:15:6: warning: unused variable 'res' [-Wunused-variable]
   15 |   ll res= 0;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 28 ms 2456 KB Output is partially correct - L* = 37
2 Partially correct 32 ms 2424 KB Output is partially correct - L* = 37
3 Partially correct 23 ms 2396 KB Output is partially correct - L* = 37
4 Partially correct 23 ms 2372 KB Output is partially correct - L* = 37
5 Partially correct 24 ms 2396 KB Output is partially correct - L* = 37
6 Partially correct 23 ms 2624 KB Output is partially correct - L* = 37
7 Partially correct 24 ms 2384 KB Output is partially correct - L* = 37
8 Partially correct 22 ms 2372 KB Output is partially correct - L* = 37
9 Partially correct 23 ms 2396 KB Output is partially correct - L* = 37
10 Partially correct 22 ms 2392 KB Output is partially correct - L* = 37
11 Partially correct 24 ms 2396 KB Output is partially correct - L* = 37
12 Partially correct 30 ms 2412 KB Output is partially correct - L* = 37
13 Partially correct 37 ms 2372 KB Output is partially correct - L* = 37
14 Partially correct 22 ms 2500 KB Output is partially correct - L* = 37
15 Partially correct 23 ms 2608 KB Output is partially correct - L* = 37
16 Partially correct 23 ms 2400 KB Output is partially correct - L* = 37
17 Partially correct 33 ms 2340 KB Output is partially correct - L* = 37
18 Partially correct 25 ms 2396 KB Output is partially correct - L* = 37
19 Partially correct 23 ms 2396 KB Output is partially correct - L* = 37
20 Partially correct 24 ms 2480 KB Output is partially correct - L* = 37
21 Partially correct 22 ms 2392 KB Output is partially correct - L* = 37
22 Partially correct 41 ms 2372 KB Output is partially correct - L* = 38
23 Partially correct 25 ms 2640 KB Output is partially correct - L* = 37
24 Partially correct 23 ms 2404 KB Output is partially correct - L* = 37
25 Partially correct 24 ms 2560 KB Output is partially correct - L* = 37
26 Partially correct 22 ms 2396 KB Output is partially correct - L* = 37
27 Partially correct 23 ms 2632 KB Output is partially correct - L* = 37
28 Partially correct 28 ms 2544 KB Output is partially correct - L* = 37
29 Partially correct 26 ms 2492 KB Output is partially correct - L* = 37
30 Partially correct 22 ms 2488 KB Output is partially correct - L* = 37
31 Partially correct 28 ms 2436 KB Output is partially correct - L* = 38
32 Partially correct 32 ms 2612 KB Output is partially correct - L* = 37
33 Partially correct 23 ms 2396 KB Output is partially correct - L* = 37
34 Partially correct 26 ms 2464 KB Output is partially correct - L* = 37
35 Partially correct 30 ms 2372 KB Output is partially correct - L* = 37
36 Partially correct 26 ms 2544 KB Output is partially correct - L* = 37
37 Partially correct 27 ms 2464 KB Output is partially correct - L* = 37
38 Partially correct 25 ms 2392 KB Output is partially correct - L* = 37
39 Partially correct 27 ms 2468 KB Output is partially correct - L* = 37
40 Partially correct 26 ms 2304 KB Output is partially correct - L* = 37