답안 #1005407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005407 2024-06-22T12:11:15 Z vjudge1 레지스터 (IOI21_registers) C++17
23 / 100
1 ms 604 KB
#include <bits/stdc++.h>
#include "registers.h"

#define all(x) (x).begin(),(x).end()
using namespace std;

using ll = long long;
using ld = long double;

//#define int ll
#define sz(x) ((int)(x).size())

using pii = pair<int,int>;
using tii = tuple<int,int,int>;

const int BSIZE = 2000;

namespace Utils {
   vector<bool> tobits(int x) {
      vector<bool> val;
      if(x == 0) { val.emplace_back(0); return val; }
      while(x > 0) {
         val.emplace_back(x & 1);
         x >>= 1;
      }
      return val;
   }
   vector<bool> multiply(vector<bool> v, int times) {
      vector<bool> R;
      while(times) {
         if(times & 1)
            copy(all(v), back_inserter(R));
         times >>= 1;
         auto X = v;
         copy(all(X), back_inserter(v));
      }
      return R;
   }
   vector<bool> concat(vector<bool> a, vector<bool> b) { copy(all(b), back_inserter(a)); return a; }
   vector<bool> ceil(vector<bool> a) {
      a.resize(BSIZE, 0);
      return a;
   }
}
using namespace Utils;

#warning LEFT INSEAMNA CA SE MISCA i --> i - p (adica la stanga)
namespace PulaMea {
   void amove(int t, int y) { append_move(t, y); }
   void astore(int t, vector<bool> a) { append_store(t, a); }
   void aand(int t, int x, int y) { append_and(t, x, y); }
   void aor(int t, int x, int y) { append_or(t, x, y); }
   void axor(int t, int x, int y) { append_xor(t, x, y); }
   void anot(int t, int x) { append_not(t, x); }
   void aright(int t, int x, int y) { append_left(t, x, y); }
   void aleft(int t, int x, int y) { append_right(t, x, y); }
   void asum(int t, int x, int y) { append_add(t, x, y); }
   void print(int t) { append_print(t); }
}
using namespace PulaMea;

#define plus ashgafshasiuhqeuiasf
const int plus = 99;
const int onesingle = 98;
const int onlyplus = 97;
const int ender = 96;
const int not_ender = 95;
const int inner = 94;
const int not_inner = 93;
const int onlyhere = 92;
int forinternuse = 3;

int forspaces = 91;
map<int, int> atrspace;

int foundsofar = 0;

void divide(int node, int n, int k, int q, int space) {
   int  times = n - 1;
   times += times % 2;
   
   for(int i = 0; i < times; i++) {
      int even = 25, odd = node, thirdparty = 1, aux = 2, aux_2 = 3;
      int nnode = 14;
      if(i % 2 == 1) {
         odd = 10;
         aand(nnode, node, inner);
         aleft(nnode, nnode, k);
         aand(node, not_inner, node);
         swap(nnode, node);
      }
      
      auto spaces = multiply(tobits(0), space);
      
      int simple;
      if(atrspace.count(space) == 0) 
         astore(atrspace[space] = (simple = (forspaces--)), 
                     ceil(multiply(concat(concat(multiply(tobits(1), k), spaces), concat(multiply(tobits(0), k), spaces)), (BSIZE / (2 * (k + space))))));
      else
         simple = atrspace[space];
      //cerr << simple << '\n';
      
      aand(even, node, simple);
      aleft(odd, node, k + space);
      aand(odd, odd, simple);
      
      int wordsize = (k + space) * 2;
      
      anot(aux, even);
      
      asum(thirdparty, odd, aux);
      aand(thirdparty, thirdparty, onlyplus);
      
      for(int i = 1; i <= k; i *= 2) {
         aleft(aux, thirdparty, i);
         aor(thirdparty, aux, thirdparty);
      }
      
      axor(aux_2, odd, even);
      aand(aux, thirdparty, odd);
      anot(thirdparty, thirdparty);
      aand(thirdparty, thirdparty, even);
      asum(odd, thirdparty, aux); // unde le punem pe alea mici
      axor(even, odd, aux_2);
      
      aright(even, even, k);
      aor(odd, odd, even);
      
      
      if(n % 2 == 1) {
         aand(aux, ender, odd);
         aleft(aux, aux, k);
         aor(odd, odd, aux);
         aand(odd, odd, onlyhere);
      }
      
      node = odd;
      if(i % 2 == 1) {
         aright(node, node, k);
         aor(nnode, node, nnode);
         swap(node, nnode);
      }
      //append_print(node);
   }
   return;
}

void construct_instructions(int s, int n, int k, int q) { 
   int space = 0;
   auto spaces = multiply(tobits(0), space);
   astore(plus, ceil(multiply(concat(concat(multiply(tobits(1), k + 1), spaces), concat(multiply(tobits(0), k - 1), spaces)), (BSIZE / (2 * (k + space))))));
   astore(onlyplus, ceil(multiply(concat(concat(multiply(tobits(0), k), tobits(1)), multiply(tobits(0), space * 2 + k - 1)), BSIZE / (2 * (k + space)))));
   astore(onesingle, ceil(multiply(tobits(1), k)));
   astore(ender, ceil(concat(multiply(tobits(0), n * k), multiply(tobits(1), k))));
   astore(inner, ceil(concat(multiply(tobits(0), k), multiply(tobits(1), k * (n - 1 - (n - 1) % 2)))));
   astore(onlyhere, ceil(multiply(tobits(1), k * n)));
   anot(not_ender, ender);
   anot(not_inner, inner);
   divide(0, n, k, q, 0);
   return;
}


/**
      Istenem! Nu poate fi real.
-- Surse verificate
*/

Compilation message

registers.cpp:47:2: warning: #warning LEFT INSEAMNA CA SE MISCA i --> i - p (adica la stanga) [-Wcpp]
   47 | #warning LEFT INSEAMNA CA SE MISCA i --> i - p (adica la stanga)
      |  ^~~~~~~
registers.cpp: In function 'void divide(int, int, int, int, int)':
registers.cpp:107:11: warning: unused variable 'wordsize' [-Wunused-variable]
  107 |       int wordsize = (k + space) * 2;
      |           ^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Incorrect min value
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Incorrect 1 ms 604 KB Incorrect sorting
5 Halted 0 ms 0 KB -