답안 #1005362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005362 2024-06-22T11:11:15 Z vjudge1 레지스터 (IOI21_registers) C++17
23 / 100
1 ms 764 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;
int forinternuse = 3;

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

int foundsofar = 0;

void divide(int node, int n, int k, int q, int space) {
   if(n == 1) {
      print(node);
      if(foundsofar == 0)
         astore(0, ceil(tobits(0)));
      aright(node, node, foundsofar * k);
      aor(0, 0, node);
      foundsofar++;
      return;
   }
   int even = ++forinternuse, odd = ++forinternuse, thirdparty = 1, aux = 2, aux_2 = 3;
   
   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];
   
   aand(even, node, simple);
   aleft(odd, node, k + space);
   aand(odd, odd, simple);
   
   int L = n / 2, R = n - n / 2;
   
   for(int i = 0; i < R; i++) {
      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);
      
      if(i != R - 1) {
         aand(aux, even, onesingle);
         aright(aux, aux, R * wordsize);
         aor(even, even, aux);
         aleft(even, even, wordsize);
      }
   }
   print(odd);
   print(even);
   
   divide(odd, L, k, q, space + k + space);
   divide(even, R, k, q, space + k + space);
   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)));
   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)
      |  ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 764 KB Wrong answer detected in grader
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 764 KB Wrong answer detected in grader
4 Halted 0 ms 0 KB -