Submission #557021

# Submission time Handle Problem Language Result Execution time Memory
557021 2022-05-04T14:46:53 Z cadmiumsky Broken Device (JOI17_broken_device) C++14
100 / 100
46 ms 2464 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
deque<int> bits;
const int nmax = 205;
int occ[nmax];
vector<int> toset; //two
void myset(int val) { toset.push_back(val); }

void calc(int poz) {  
  int coef = (occ[poz] << 2) | (occ[poz + 1] << 1) | (occ[poz + 2]);
  if(__builtin_popcount(coef) >= 2) {
    myset(0);
    myset(0);
    myset(0);
    return;
  }
  switch(coef) {
    case 0b001: {
      if(bits[0] == 0) {
        //if(bits[1] == 0) // 0
          myset(1),
          myset(0),
          myset(0);
        //else // 01
          //myset(1),
          //myset(1),
          //myset(0),
          //bits.pop_front();
      }
      else // 1
        myset(0),
        myset(1),
        myset(0);
      break;
    }
    case 0b010: {
      if(bits[0] == 0) // 0
        myset(1),
        myset(0),
        myset(0);
      else {
        if(bits[1] == 0) // 10
          myset(0),
          myset(0),
          myset(1);
        else            // 11
          myset(1),
          myset(0),
          myset(1);
        bits.pop_front();
      }
      break;
    }
    case 0b100: {
      if(bits[0] == 0) // 0
        myset(0),
        myset(1),
        myset(1);
      else            // 1
        myset(0),
        myset(1),
        myset(0);
      break;
    }
    case 0b000: {
      int u = (bits[0] << 1) | bits[1];
      switch(u) {
        case 0b00:
          myset(1),
          myset(1),
          myset(1);
          break;
        case 0b01:
          myset(1),
          myset(1),
          myset(0);
          break;
        case 0b10:
          myset(0),
          myset(0),
          myset(1);
          break;
        case 0b11:
          myset(1),
          myset(0),
          myset(1);
          break;
      }
      bits.pop_front();
    }
  }
  bits.pop_front();
}

void Anna( int n, long long x, int k, int p[] ){
  bits.clear();
  toset.clear();
  for(int i = 59; i >= 0; i--)
    bits.push_back((x & (1LL << i)) > 0LL);
  for(int i = 0; i <= 300; i++)
    bits.push_back(0);
  for(int i = 0; i < k; i++)
    occ[p[i]] = 1;
  for(int i = 0; i < n; i += 3)
    calc(i), occ[i] = occ[i + 1] = occ[i + 2] = 0;
  for(int i = 0; i < n; i++)
    Set(i, toset[i]);
  
  return;
}
//\
1001001010010010001001010010010001001010010010001001010010010001011010101010100\
10010010100100100010010100100100010010100100100010011000000\
10010010100100100010010100100100010010100100100010010100100\
10010110101001011010100101101010010110101001011010101000000\
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

string rez;
void myset(string s) { rez += s;}
vector<int> a;
void calcB(int poz) {
  int coef = (a[poz] << 2) | (a[poz + 1] << 1) | a[poz + 2];
  switch(coef) {
    case 0b111: 
      myset("00");
      break;
    case 0b110:
      myset("01");
      break;
    case 0b101:
      myset("11");
      break;
    case 0b011:
      myset("0");
      break;
    case 0b001:
      myset("10");
      break;
    case 0b010:
      myset("1");
      break;
    case 0b100:
      myset("0");
      break;
    case 0b000:
      break;
  }
  return;
}

long long Bruno( int N, int A[] ){
  for(int i = 0; i < N; i++)
    a.push_back(A[i]);
  for(int i = 0; i < N; i += 3)
    calcB(i);
  long long X = 0;
  for(int i = 0; i < 60; i++)
    X = (X << 1) + (long long)(rez[i] - '0');
  a.clear();
  rez = "";
  return X;
}

Compilation message

Anna.cpp:112:3: warning: backslash-newline at end of file
  112 | //\
      |    
Anna.cpp:112:1: warning: multi-line comment [-Wcomment]
  112 | //\
      | ^
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2328 KB Output is correct - L* = 40
2 Correct 38 ms 2300 KB Output is correct - L* = 40
3 Correct 34 ms 2404 KB Output is correct - L* = 40
4 Correct 32 ms 2332 KB Output is correct - L* = 40
5 Correct 33 ms 2244 KB Output is correct - L* = 40
6 Correct 34 ms 2340 KB Output is correct - L* = 40
7 Correct 31 ms 2280 KB Output is correct - L* = 40
8 Correct 37 ms 2260 KB Output is correct - L* = 40
9 Correct 34 ms 2260 KB Output is correct - L* = 40
10 Correct 38 ms 2340 KB Output is correct - L* = 40
11 Correct 33 ms 2464 KB Output is correct - L* = 40
12 Correct 41 ms 2236 KB Output is correct - L* = 40
13 Correct 34 ms 2384 KB Output is correct - L* = 40
14 Correct 36 ms 2248 KB Output is correct - L* = 40
15 Correct 32 ms 2212 KB Output is correct - L* = 40
16 Correct 40 ms 2344 KB Output is correct - L* = 40
17 Correct 33 ms 2416 KB Output is correct - L* = 40
18 Correct 38 ms 2392 KB Output is correct - L* = 40
19 Correct 38 ms 2236 KB Output is correct - L* = 40
20 Correct 34 ms 2248 KB Output is correct - L* = 40
21 Correct 32 ms 2256 KB Output is correct - L* = 40
22 Correct 33 ms 2236 KB Output is correct - L* = 40
23 Correct 34 ms 2356 KB Output is correct - L* = 40
24 Correct 36 ms 2272 KB Output is correct - L* = 40
25 Correct 39 ms 2264 KB Output is correct - L* = 40
26 Correct 39 ms 2244 KB Output is correct - L* = 40
27 Correct 34 ms 2316 KB Output is correct - L* = 40
28 Correct 35 ms 2296 KB Output is correct - L* = 40
29 Correct 32 ms 2404 KB Output is correct - L* = 40
30 Correct 33 ms 2232 KB Output is correct - L* = 40
31 Correct 33 ms 2232 KB Output is correct - L* = 40
32 Correct 32 ms 2228 KB Output is correct - L* = 40
33 Correct 46 ms 2352 KB Output is correct - L* = 40
34 Correct 32 ms 2348 KB Output is correct - L* = 40
35 Correct 35 ms 2368 KB Output is correct - L* = 40
36 Correct 33 ms 2256 KB Output is correct - L* = 40
37 Correct 36 ms 2232 KB Output is correct - L* = 40
38 Correct 41 ms 2376 KB Output is correct - L* = 40
39 Correct 36 ms 2320 KB Output is correct - L* = 40
40 Correct 35 ms 2436 KB Output is correct - L* = 40