답안 #1005267

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005267 2024-06-22T09:28:56 Z vjudge1 레지스터 (IOI21_registers) C++17
33 / 100
1 ms 348 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 simple = 99;
const int plus = 98;
const int onesingle = 97;
const int onlyplus = 96;


void divide(int n, int k, int q, int space) {
   int even = 1, weirdeven = 2, odd = 0, thirdparty = 3, aux = 4;
   
   auto spaces = multiply(tobits(0), space);
   
   astore(simple, ceil(multiply(concat(concat(multiply(tobits(1), k), spaces), concat(multiply(tobits(0), k), spaces)), (BSIZE / (2 * (k + space))))));
   
   aand(even, 0, simple);
   aleft(odd, 0, k + space);
   aand(odd, odd, simple);
   
   if(n % 2 == 1) {
      aand(aux, odd, onesingle);
      aright(aux, aux, (k + space + k + space) * (n / 2));
      aor(odd, odd, aux);
      n++;
   }
   
   //print(even);
   //print(odd);
   
   //print(odd);
   
   anot(weirdeven, even);
   //aand(weirdeven, weirdeven, plus);
   
   //print(weirdeven);
   //print(odd);
   
   asum(thirdparty, odd, weirdeven);
   aand(thirdparty, thirdparty, onlyplus);
   print(thirdparty);
   
   //print(thirdparty);
   
   aleft(thirdparty, thirdparty, k);
   for(int i = 1; i < k; i *= 2) {
      aright(aux, thirdparty, i);
      aor(thirdparty, aux, thirdparty);
   }
   
   aand(aux, thirdparty, odd);
   anot(thirdparty, thirdparty);
   aand(thirdparty, thirdparty, even);
   asum(odd, thirdparty, aux);
   
   //append_print(0);
   //print(0);
   if(n == 2) return;
   divide(n / 2, 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(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 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Incorrect sorting
2 Halted 0 ms 0 KB -