답안 #1078526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078526 2024-08-27T19:14:38 Z anton Broken Device (JOI17_broken_device) C++17
85 / 100
47 ms 3024 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[] ){
  ll XOR = 22334263684363467LL;
  srand(42);

  N = _N;
  X = _X;

  vector<int> base3;
  X = X^XOR;
  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 =(rand()%base3.size())*2;
  //cout<<"blocks "<<base3.size()<<endl;
  vector<bool> written(base3.size(), false);
  int nb_rem = base3.size();
  while(cur_pos<N && nb_rem>0){
    if((!info_bits[cur_bit]) || (!broken[cur_pos])){
      if((!info_bits[cur_bit+1]) || (!broken[cur_pos+1])){
        if(broken[cur_pos]|| broken[cur_pos+1]){
        }
        //cout<<cur_pos<<", "<<cur_bit<<" | ";
        res[cur_pos] =info_bits[cur_bit];
        res[cur_pos+1] = info_bits[cur_bit+1];
        written[cur_bit/2] = true;
        nb_rem--;
      }
    }
    if(nb_rem == 0){
      break;
    }
    cur_bit = (rand()%base3.size())*2;
    while(written[cur_bit/2]){
      cur_bit = (rand()%base3.size())*2;
    }
    
    cur_pos+=2;
  }
  //cout<<endl;
  for(int i = 0; i<N; i++){
    Set(i, res[i]);
  }
}
#include "Brunolib.h"
#include<bits/stdc++.h>

using namespace std;
#define ll long long 

long long Bruno( int N, int A[] ){
  ll XOR = 22334263684363467LL;
  srand(42);


  
  ll res= 0;

  /*for(auto e: bits){
    //cout<<e<<" ";
  }
  //cout<<endl;*/
  int nb_blocks = 0;
  for(int i = 0; i<N; i+=2){
    if(A[i] == 0 && A[i+1] == 0){
    }
    else{
      nb_blocks++;
    }
  }
  vector<int> bits(2*nb_blocks);

  int block_id = (rand()%nb_blocks)*2;
  //cout<<"blocks "<<nb_blocks<<endl;

  int nb_rem = nb_blocks;
  for(int i = 0; i<N && nb_rem>0; i+=2){
    if(A[i] == 0 && A[i+1] == 0){
      
    }
    else{
      //cout<<i<<", "<<block_id<<" | ";
      bits[block_id] = A[i];
      bits[block_id+1] = A[i+1];
      nb_rem--;
    }
    if(nb_rem == 0){
      break;
    }
    block_id = (rand()%nb_blocks)*2;
    while((bits[block_id]!= 0) || (bits[block_id+1]!=0)){
      block_id = (rand()%nb_blocks)*2;
    }
  }
  //cout<<endl;
  vector<int> base3(nb_blocks);

  for(int i = 0; i<nb_blocks*2; i+=2){
    if(bits[i] == 0 && bits[i+1] == 1){
      base3[i/2] = 0;
    }
    if(bits[i] == 1 && bits[i+1] == 0){
      base3[i/2] = 1;

    }
    if(bits[i] == 1 && bits[i+1] == 1){
      base3[i/2] = 2;
    }
  }

  ll X= 0;

  while(base3.size()>0){
    X*=3LL;
    X += (ll)(base3.back());
    base3.pop_back();
  }
  X = X^XOR;

  //cout<<X<<endl;
  return X;

}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:34:8: warning: variable 'mySet' set but not used [-Wunused-but-set-variable]
   34 |   auto mySet = [&](int pos, int val){
      |        ^~~~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:13:6: warning: unused variable 'res' [-Wunused-variable]
   13 |   ll res= 0;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 32 ms 2772 KB Output is partially correct - L* = 38
2 Partially correct 32 ms 2752 KB Output is partially correct - L* = 38
3 Partially correct 31 ms 2688 KB Output is partially correct - L* = 37
4 Partially correct 38 ms 2680 KB Output is partially correct - L* = 39
5 Partially correct 35 ms 2776 KB Output is partially correct - L* = 39
6 Partially correct 38 ms 2752 KB Output is partially correct - L* = 38
7 Partially correct 37 ms 2776 KB Output is partially correct - L* = 38
8 Partially correct 31 ms 2776 KB Output is partially correct - L* = 38
9 Partially correct 32 ms 2776 KB Output is partially correct - L* = 38
10 Partially correct 31 ms 2776 KB Output is partially correct - L* = 39
11 Partially correct 32 ms 2776 KB Output is partially correct - L* = 38
12 Partially correct 30 ms 2852 KB Output is partially correct - L* = 38
13 Partially correct 32 ms 2776 KB Output is partially correct - L* = 38
14 Partially correct 36 ms 2796 KB Output is partially correct - L* = 38
15 Partially correct 35 ms 2848 KB Output is partially correct - L* = 39
16 Partially correct 39 ms 2776 KB Output is partially correct - L* = 37
17 Partially correct 32 ms 2680 KB Output is partially correct - L* = 37
18 Partially correct 33 ms 2772 KB Output is partially correct - L* = 39
19 Partially correct 31 ms 2776 KB Output is partially correct - L* = 37
20 Partially correct 38 ms 2688 KB Output is partially correct - L* = 37
21 Partially correct 33 ms 2772 KB Output is partially correct - L* = 38
22 Partially correct 31 ms 2772 KB Output is partially correct - L* = 39
23 Partially correct 39 ms 2764 KB Output is partially correct - L* = 38
24 Partially correct 32 ms 2776 KB Output is partially correct - L* = 39
25 Partially correct 32 ms 2860 KB Output is partially correct - L* = 37
26 Partially correct 40 ms 2804 KB Output is partially correct - L* = 38
27 Partially correct 34 ms 2684 KB Output is partially correct - L* = 37
28 Partially correct 31 ms 2772 KB Output is partially correct - L* = 38
29 Partially correct 33 ms 2700 KB Output is partially correct - L* = 37
30 Partially correct 31 ms 2784 KB Output is partially correct - L* = 38
31 Partially correct 32 ms 3024 KB Output is partially correct - L* = 38
32 Partially correct 47 ms 2572 KB Output is partially correct - L* = 38
33 Partially correct 31 ms 2700 KB Output is partially correct - L* = 37
34 Partially correct 31 ms 2772 KB Output is partially correct - L* = 37
35 Partially correct 31 ms 2776 KB Output is partially correct - L* = 38
36 Partially correct 33 ms 2752 KB Output is partially correct - L* = 38
37 Partially correct 34 ms 2752 KB Output is partially correct - L* = 38
38 Partially correct 32 ms 2772 KB Output is partially correct - L* = 39
39 Partially correct 32 ms 2736 KB Output is partially correct - L* = 38
40 Partially correct 31 ms 2704 KB Output is partially correct - L* = 39