QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#325789#3098. Ancient Machinebachbeo20070 26ms9620kbC++202.4kb2024-02-11 23:04:292024-02-11 23:04:30

Judging History

你现在查看的是最新测评结果

  • [2024-02-11 23:04:30]
  • 评测
  • 测评结果:0
  • 用时:26ms
  • 内存:9620kb
  • [2024-02-11 23:04:29]
  • 提交

Anna

#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

namespace{
    int F[50];
}

int bit_to_fib(string s){
    int total=0,pos=39;
    while(pos>=0){
        if(s[pos]=='1') total+=F[pos],pos-=2;
        else pos--;
    }
    //cout << s << ' ' << total << '\n';
    return total;
}

void Anna(int N, std::vector<char> S) {
    F[0]=1;F[1]=2;
    for(int i=2;i<=40;i++) F[i]=(F[i-1]+F[i-2]);

    int f=-1,lst=-1;
    string res;
    for(int i=0;i<N;i++){
        if(f==-1){
            if(S[i]=='X') f=i;
            else res+='0';
        }
        else if(S[i]=='Z'){
            if(S[i-1]=='Z') res.back()='0';
            res+='1';
        }
        else res+='0';
    }

    bool check=true;
    if(f!=-1 && (f+1==N || res[f+1]=='0')) res[f]='1';
    else check=false;

    while(N%40!=0) res+='0',N++;
    for(int i=0;i<N;i+=40){
        string cur;
        for(int j=0;j<40;j++) cur+=res[i+j];
        int total=bit_to_fib(cur);
        for(int j=0;j<28;j++) Send(total>>j&1);
    }
    if(!check){
        if(f==-1) Send(0);
        else Send(1);
    }
}

Bruno

#include "Bruno.h"
#include<bits/stdc++.h>
using namespace std;

namespace{
    int F[50];
}

string fib_to_bit(int total){
    string res;
    int pos=39;
    while(pos>=0){
        if(total>=F[pos]) res+="10",total-=F[pos],pos-=2;
        else res+='0',pos--;
    }
    if((int)res.length()>40) res.pop_back();
    reverse(res.begin(),res.end());
    return res;
}

void Bruno(int N, int L,vector<int> A) {

    F[0]=1;F[1]=2;
    for(int i=2;i<=40;i++) F[i]=F[i-1]+F[i-2];

    int f=-1;
    if(L>70000){
        if(A.back()!=0){
            for(int i=0;i<L;i++) if(A[i]==1){f=i-1;break;}
        }
        A.pop_back();
        L--;
    }
    else{
        for(int i=0;i<L;i++) if(A[i]==1){
            f=i;A[i]=0;
            break;
        }
    }
    if(f==-1){
        for(int i=0;i<N;i++) Remove(i);
        return;
    }
    string s;
    for(int i=0;i<L;i+=28){
        int total=0;
        for(int j=0;j<28;j++) total+=A[i+j]<<j;
        s+=fib_to_bit(total);
    }
    while((int)s.length()>N) s.pop_back();

    for(int i=0;i<f;i++) Remove(i);

    int lst=f;
    for(int i=f+1;i<N;i++){
        if(s[i]=='1'){
            for(int j=i-1;j>lst;j--) Remove(j);
            Remove(i);lst=i;
        }
    }
    for(int i=lst+1;i<N;i++) Remove(i);
    Remove(f);
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3752kb

input:

18
Y X Y Z X Z X X Z Z Y Y Z Y Y Z X X

output:

29
01100000101000000000000000001

input:

29
01100000101000000000000000001

output:

0 29 2

result:

wrong answer your query is valid but your solution is not optimal: read 2 but expected 3

Subtask #2:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 26ms
memory: 9620kb

input:

100000
X Z X Z Z X Y Z Y X Y X Z Z Z Y X Z Y X Y Y X Y Y Y Z Y Z Z Y X X Y X X Y Y X X X Z Y Y Y Z Z Z Z Y X Y Y Z Z Z X Y Z X X X X Y X Y X X Z X Z Z Z X Y X X X Z X Z X X X Y Y Y Y Z X X Y Z Y Y X Z X Z Z Z Z Z Y Z Y X Y Y Y Y X Z Z Y Z Z Y Z Z Z X Z Z X X Z Z Z Z X X Z Y Y Z Y Y Z Z Y Y Z Y Z Y Z...

output:

70000
111111111011110111110000000010011111000010101000011110111110100010110011111001011101111001011101011101110010101001010000100110101101011000100111101001110101101111011100010011100101101010001110101101100110101111000010110011011010111110011001111110101100100101101111000101001110000000000111101111...

input:

70000
111111111011110111110000000010011111000010101000011110111110100010110011111001011101111001011101011101110010101001010000100110101101011000100111101001110101101111011100010011100101101010001110101101100110101111000010110011011010111110011001111110101100100101101111000101001110000000000111101111...

output:

0 70000 11147

result:

wrong answer your query is valid but your solution is not optimal: read 11147 but expected 22133