QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#466638#3098. Ancient MachineBalintR5 42ms10000kbC++204.2kb2024-07-07 23:32:182024-07-07 23:32:18

Judging History

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

  • [2024-07-07 23:32:18]
  • 评测
  • 测评结果:5
  • 用时:42ms
  • 内存:10000kb
  • [2024-07-07 23:32:18]
  • 提交

Anna

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

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef complex<double> cpx;
template <typename T> using minPq = priority_queue<T, vector<T>, greater<T>>;
#define ms(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define fs first
#define sn second
#define ALL(v) begin(v), end(v)
#define SZ(v) ((int) (v).size())
#define lbv(v, x) (lower_bound(ALL(v), x) - (v).begin())
#define ubv(v, x) (upper_bound(ALL(v), x) - (v).begin())
template <typename T> inline void UNIQUE(vector<T> &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
#define FR(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define dbg(x) {cerr << #x << ' ' << x << endl;}
#define dbgArr(arr, n) {cerr << #arr; FR(_i, n) cerr << ' ' << (arr)[_i]; cerr << endl;}
template <typename T, typename U>
ostream& operator<<(ostream &os, pair<T, U> p){return os << "(" << p.fs << ", " << p.sn << ")";}

namespace { // clown
    const int B = 28;
    const int K = 40;
    ll fib[K];

    void init(){
        fib[0] = 1;
        fib[1] = 2;
        FOR(i, 2, K) fib[i] = fib[i-1] + fib[i-2];
    }
}

void Anna(int n, vector<char> str){
    init();
    str.pb('X');

    vi vec;
    bool foundX = false;
    FR(i, n-1){
        if(!foundX){
            if(str[i] == 'X') vec.pb(1), vec.pb(0), foundX = true;
            else vec.pb(0);
        }
        else {
            vec.pb(str[i] == 'Z' && str[i+1] != 'Z');
        }
    }

    while(SZ(vec) % K) vec.pb(0);

    for(int i = 0; i < SZ(vec); i += K){
        int x = 0;
        FR(j, K) x += vec[i+j]*fib[j];
        assert(x < (1<<B));
        FR(j, B) Send((x >> j) & 1);
    }
}

Bruno

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

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef complex<double> cpx;
template <typename T> using minPq = priority_queue<T, vector<T>, greater<T>>;
#define ms(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define fs first
#define sn second
#define ALL(v) begin(v), end(v)
#define SZ(v) ((int) (v).size())
#define lbv(v, x) (lower_bound(ALL(v), x) - (v).begin())
#define ubv(v, x) (upper_bound(ALL(v), x) - (v).begin())
template <typename T> inline void UNIQUE(vector<T> &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
#define FR(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define dbg(x) {cerr << #x << ' ' << x << endl;}
#define dbgArr(arr, n) {cerr << #arr; FR(_i, n) cerr << ' ' << (arr)[_i]; cerr << endl;}
template <typename T, typename U>
ostream& operator<<(ostream &os, pair<T, U> p){return os << "(" << p.fs << ", " << p.sn << ")";}

namespace { // clown
    const int B = 28;
    const int K = 40;
    ll fib[K];

    void init(){
        fib[0] = 1;
        fib[1] = 2;
        FOR(i, 2, K) fib[i] = fib[i-1] + fib[i-2];
    }
}

void Bruno(int n, int l, vector<int> vec){
    vi arr(l/B*K);
    init();
    for(int a = 0, b = 0; b < SZ(vec); b += B, a += K){
        int x = 0;
        FR(j, B) x += vec[b+j] << j;
        FORR(j, K-1, 0) if(x >= fib[j]) x -= fib[j], arr[a+j] = 1;
    }
    arr[n] = 1;

    vi ps;
    FR(i, SZ(arr)) if(arr[i]) ps.pb(i);

    if(SZ(ps) == 1){
        FR(i, n) Remove(i);
        return;
    }

    FOR(i, 1, SZ(ps)) ps[i]--;

    //dbgArr(ps, SZ(ps));

    vector<bool> rem(n);
    FOR(i, 1, SZ(ps)){
        FORR(j, ps[i]-1, ps[i-1]+1) Remove(j), rem[j] = true;
        Remove(ps[i]), rem[ps[i]] = true;
    }
    FR(i, n) if(!rem[i]) Remove(i), rem[i] = true;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 100
Accepted
time: 2ms
memory: 4080kb

input:

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

output:

28
1001010010110000000000000000

input:

28
1001010010110000000000000000

output:

0 28 3

result:

ok n = 18, D = 28, L = 3

Test #2:

score: 100
Accepted
time: 0ms
memory: 3868kb

input:

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

output:

28
1101011000101000000000000000

input:

28
1101011000101000000000000000

output:

0 28 3

result:

ok n = 18, D = 28, L = 3

Test #3:

score: 100
Accepted
time: 0ms
memory: 3788kb

input:

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

output:

28
1101111101001000000000000000

input:

28
1101111101001000000000000000

output:

0 28 2

result:

ok n = 18, D = 28, L = 2

Test #4:

score: 100
Accepted
time: 0ms
memory: 4076kb

input:

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

output:

28
0101111000101000000000000000

input:

28
0101111000101000000000000000

output:

0 28 2

result:

ok n = 18, D = 28, L = 2

Test #5:

score: 100
Accepted
time: 0ms
memory: 3808kb

input:

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

output:

28
0101010011000000000000000000

input:

28
0101010011000000000000000000

output:

0 28 5

result:

ok n = 18, D = 28, L = 5

Test #6:

score: 100
Accepted
time: 0ms
memory: 3784kb

input:

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

output:

28
1111010011100000000000000000

input:

28
1111010011100000000000000000

output:

0 28 2

result:

ok n = 18, D = 28, L = 2

Test #7:

score: 100
Accepted
time: 0ms
memory: 3804kb

input:

3
X Y Z

output:

28
1000000000000000000000000000

input:

28
1000000000000000000000000000

output:

0 28 1

result:

ok n = 3, D = 28, L = 1

Test #8:

score: 100
Accepted
time: 0ms
memory: 3812kb

input:

3
Z Y X

output:

28
0000000000000000000000000000

input:

28
0000000000000000000000000000

output:

0 28 0

result:

ok n = 3, D = 28, L = 0

Test #9:

score: 100
Accepted
time: 0ms
memory: 3804kb

input:

18
X X X X X X X X X X X X X X X X X X

output:

28
1000000000000000000000000000

input:

28
1000000000000000000000000000

output:

0 28 0

result:

ok n = 18, D = 28, L = 0

Test #10:

score: 100
Accepted
time: 0ms
memory: 3784kb

input:

18
Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y

output:

28
0000000000000000000000000000

input:

28
0000000000000000000000000000

output:

0 28 0

result:

ok n = 18, D = 28, L = 0

Test #11:

score: 100
Accepted
time: 0ms
memory: 3808kb

input:

18
Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z

output:

28
0000000000000000000000000000

input:

28
0000000000000000000000000000

output:

0 28 0

result:

ok n = 18, D = 28, L = 0

Subtask #2:

score: 0
Wrong Answer

Test #12:

score: 100
Accepted
time: 42ms
memory: 10000kb

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
001101010110110010010100000010010010010110000000000101011110110111101000101101010010001111001100110110100111101101001100000101111000100111010100011110111100110100111001000010110101111101011010100111011001001100010111111011000110100000001111001010110001000101000011011111010100100010000110100010...

input:

70000
001101010110110010010100000010010010010110000000000101011110110111101000101101010010001111001100110110100111101101001100000101111000100111010100011110111100110100111001000010110101111101011010100111011001001100010111111011000110100000001111001010110001000101000011011111010100100010000110100010...

output:

0 70000 22133

result:

points 1.0 n = 100000, D = 70000, L = 22133

Test #13:

score: 100
Accepted
time: 42ms
memory: 9864kb

input:

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

output:

70000
111100000010011111000101111010001000010111000011001001011110111110110010001111010100011110110011101011000010011010111111000001010011010000100000010010101100011110010100000000111111110101010011000001010100000101000100010110100011101111000101111010000001100011000011000010101000000010011110011110...

input:

70000
111100000010011111000101111010001000010111000011001001011110111110110010001111010100011110110011101011000010011010111111000001010011010000100000010010101100011110010100000000111111110101010011000001010100000101000100010110100011101111000101111010000001100011000011000010101000000010011110011110...

output:

0 70000 22275

result:

points 1.0 n = 100000, D = 70000, L = 22275

Test #14:

score: 100
Accepted
time: 34ms
memory: 9808kb

input:

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

output:

70000
101011001101011010011100010011011110000000000001011011100011010101111110111010010100100011110110110000100100000111111100110101101000000000001111101100001001111110111001100001011011101011011001100000110110100110110000001010001111001111001000010000001101000111000100010011110000100000010101101010...

input:

70000
101011001101011010011100010011011110000000000001011011100011010101111110111010010100100011110110110000100100000111111100110101101000000000001111101100001001111110111001100001011011101011011001100000110110100110110000001010001111001111001000010000001101000111000100010011110000100000010101101010...

output:

0 70000 22177

result:

points 1.0 n = 100000, D = 70000, L = 22177

Test #15:

score: 100
Accepted
time: 34ms
memory: 9916kb

input:

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

output:

70000
100001010010100010100110000001111101100111001101111000100000000000000110011000011000000011111010100101010110110111011001100101010011101101011111111110100101110011101100001110011000011101101010010000011001110110111100010010010011000110011010110011100110001011010110110001111111011011001111011111...

input:

70000
100001010010100010100110000001111101100111001101111000100000000000000110011000011000000011111010100101010110110111011001100101010011101101011111111110100101110011101100001110011000011101101010010000011001110110111100010010010011000110011010110011100110001011010110110001111111011011001111011111...

output:

0 70000 22192

result:

points 1.0 n = 100000, D = 70000, L = 22192

Test #16:

score: 100
Accepted
time: 42ms
memory: 9840kb

input:

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

output:

70000
111111110100001011100110110111000110001000010010000011001110000000100111011011000101101000010000110000011000110010100010110001010000101000000110011100100100110000101000011011011100001100000000100001110110011001000111000101011011101000000001010001110100001100110000101110101110100001111111010011...

input:

70000
111111110100001011100110110111000110001000010010000011001110000000100111011011000101101000010000110000011000110010100010110001010000101000000110011100100100110000101000011011011100001100000000100001110110011001000111000101011011101000000001010001110100001100110000101110101110100001111111010011...

output:

0 70000 22119

result:

points 1.0 n = 100000, D = 70000, L = 22119

Test #17:

score: 0
Wrong Answer
time: 34ms
memory: 9804kb

input:

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

output:

70000
100010010000000001001000010000100111101011011011111101100011100001110001100111000000110100111111101110001011110001100111000111111010000110000001011010110011001100010000110110001110011001001000011100110110111110110110001010001111100001111011110001100110100011011011001000001100011010100111111000...

input:

70000
100010010000000001001000010000100111101011011011111101100011100001110001100111000000110100111111101110001011110001100111000111111010000110000001011010110011001100010000110110001110011001001000011100110110111110110110001010001111100001111011110001100110100011011011001000001100011010100111111000...

output:

0 70000 22255

result:

wrong answer your query is valid but your solution is not optimal: read 22255 but expected 22256