Submission #386314

# Submission time Handle Problem Language Result Execution time Memory
386314 2021-04-06T10:59:40 Z model_code Ancient Machine (JOI21_ancient_machine) C++17
100 / 100
79 ms 8524 KB
#include "Anna.h"
#include <bits/stdc++.h>

namespace{
  int A=63,B=44;
  long long fib[100];
  void init(){
    fib[0]=1;
    fib[1]=2;
    for(int i=2;i<=A;i++){
      fib[i]=fib[i-1]+fib[i-2];
    }
  }
  long long encode(std::vector<int>y){
    reverse(y.begin(),y.end());
    long long res=0;
    for(int i=0;i<A;i++){
      if(y[i]==1)res+=fib[i];
    }
    return res;
  }
}

void Anna(int N,std::vector<char>S){
  std::vector<int>x;
  int p=0;
  while(p<N&&S[p]!='X'){
    x.push_back(0);
    p++;
  }
  if(p<N){
    x.push_back(1);
    x.push_back(0);
    p++;
  }
  for(;p<N;p++){
    if(S[p]=='Z'&&(p==N-1||S[p+1]!='Z'))x.push_back(1);
    else x.push_back(0);
  }
  while(x.size()%A!=0)x.push_back(0);
  init();
  for(int i=0;i<x.size();i+=A){
    std::vector<int>y(A);
    for(int j=0;j<A;j++){
      y[j]=x[i+j];
    }
    long long s=encode(y);
    for(long long j=0;j<B;j++)Send(s>>j&1);
  }
}
#include "Bruno.h"
#include <bits/stdc++.h>

namespace{
  std::vector<int>X;
  int A=63,B=44;
  long long fib[100];
  void init(){
    fib[0]=1;
    fib[1]=2;
    for(int i=2;i<=A;i++){
        fib[i]=fib[i-1]+fib[i-2];
    }
  }
  void decode(long long s){
    for(int i=A-1;i>=0;i--){
      if(fib[i]<=s){
        s-=fib[i];
        X.push_back(1);
      }else X.push_back(0);
    }
  }
}

void Bruno(int N,int L,std::vector<int>x){
  init();
  for(int i=0;i<L;i+=B){
    long long s=0;
    for(long long j=0;j<B;j++)s+=(long long)x[i+j]<<j;
    decode(s);
  }
  int p=0,l=0;
  while(p<N&&!X[l]){
    Remove(p);
    p++;
    l++;
  }
  int la=p,lx=p;
  p++;
  l+=2;
  for(;p<N;p++,l++){
    if(X[l]){
      for(int i=p-1;i>la;i--)Remove(i);
      Remove(p);
      la=p;
    }
  }
  for(int i=N-1;i>la;i--)Remove(i);
  if(lx<N)Remove(lx);
}

Compilation message

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for(int i=0;i<x.size();i+=A){
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 484 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 500 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 2 ms 484 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 8276 KB Output is correct
2 Correct 59 ms 8388 KB Output is correct
3 Correct 59 ms 8256 KB Output is correct
4 Correct 59 ms 8340 KB Output is correct
5 Correct 66 ms 8524 KB Output is correct
6 Correct 57 ms 8368 KB Output is correct
7 Correct 59 ms 8240 KB Output is correct
8 Correct 59 ms 8252 KB Output is correct
9 Correct 63 ms 8264 KB Output is correct
10 Correct 57 ms 8292 KB Output is correct
11 Correct 59 ms 8408 KB Output is correct
12 Correct 59 ms 8364 KB Output is correct
13 Correct 67 ms 8464 KB Output is correct
14 Correct 66 ms 8388 KB Output is correct
15 Correct 73 ms 8360 KB Output is correct
16 Correct 64 ms 8300 KB Output is correct
17 Correct 64 ms 8384 KB Output is correct
18 Correct 68 ms 8340 KB Output is correct
19 Correct 79 ms 8340 KB Output is correct
20 Correct 60 ms 8276 KB Output is correct
21 Correct 57 ms 8332 KB Output is correct
22 Correct 66 ms 8368 KB Output is correct
23 Correct 64 ms 8376 KB Output is correct
24 Correct 57 ms 8380 KB Output is correct
25 Correct 65 ms 8344 KB Output is correct
26 Correct 73 ms 8372 KB Output is correct
27 Correct 66 ms 8320 KB Output is correct
28 Correct 69 ms 8332 KB Output is correct
29 Correct 65 ms 8296 KB Output is correct
30 Correct 65 ms 8388 KB Output is correct
31 Correct 67 ms 8352 KB Output is correct
32 Correct 57 ms 8324 KB Output is correct
33 Correct 63 ms 8316 KB Output is correct