답안 #935586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935586 2024-02-29T09:31:56 Z quanlt206 Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
47 ms 9336 KB
#include "Anna.h"
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;
 
template<class A, class B>
    bool maximize(A& x, B y) {
        if (x < y) return x = y, true; else return false;
    }
template<class A, class B>
    bool minimize(A& x, B y) {
        if (x > y) return x = y, true; else return false;
    }
/* END OF TEMPLATE */
 
const int N = 1e5 + 7;
const int BLOCK = 60;
const int bit_size = 43;
 
int n, m;
 
vector<int> bit, val_remove;
 
ll f[N];
 
void convert_to_longlong(vector<int> B) {
//    cout<<"B : ";
//    for (auto x : B) cout<<x<<" "; cout<<"\n";
    ll idx = 0;
    f[0] = 1;
    f[1] = 1;
    FOR(i, 2, BLOCK) f[i] = f[i - 1] + f[i - 2];
    REP(i, 0, (int)B.size())
        if (B[i] == 1) {
            idx+=f[(int)B.size() - i];
        }
    FORD(i, bit_size, 0) Send((idx >> i) & 1);
//    exit(0);
}
 
void Convert(vector<int> A) {
    while ((int)A.size() % BLOCK != 0) A.push_back(0);
    for (int i = 0; i < (int)A.size(); i+=BLOCK) {
        vector<int> B;
        FOR(j, i, i + BLOCK - 1) B.push_back(A[j]);
        convert_to_longlong(B);
    }
}
 
void Anna(int n, vector<char> S) {
    bool kt = false;
    int i = 0;
    while (i < n) {
        if (S[i] != 'Z') {
            i++;
            continue;
        }
        int j = i;
        while (j + 1 < n && S[j + 1] == S[j]) j++;
        FOR(k, i, j - 1) S[k] = 'Y';
        i = j + 1;
    }
    vector<int> A;
    bool ok = false;
    for (auto x : S)
        if (!ok) {
            if (x == 'Y' || x == 'Z') A.push_back(0); else {
                ok = true;
                A.push_back(1);
            }
        }
        else {
            if (x == 'Z') A.push_back(1); else A.push_back(0);
        }
    Convert(A);
}
#include "Bruno.h"
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;
 
template<class A, class B>
    bool maximize(A& x, B y) {
        if (x < y) return x = y, true; else return false;
    }
template<class A, class B>
    bool minimize(A& x, B y) {
        if (x > y) return x = y, true; else return false;
    }
/* END OF TEMPLATE */
 
const int N = 1e5 + 7;
const int BLOCK = 60;
const int bit_size = 43;
 
int n, m;
 
vector<int> bit, val_remove;
 
ll f[N];
 
vector<int> convert_to_array(ll idx) {
    f[0] = 1;
    f[1] = 1;
    FOR(i, 2, BLOCK) f[i] = f[i - 1] + f[i - 2];
    cerr<<idx<<endl;
    vector<int> res;
//    cout<<idx<<"\n";
    idx++;
    REP(i, 0, BLOCK)
        if (idx > f[BLOCK - i]) {
            res.push_back(1);
            idx-=f[BLOCK - i];
        }
        else {
            res.push_back(0);
        }
//    for (auto x : res) cout<<x<<" "; cout<<"\n";
//    exit(0);
    return res;
}
 
vector<int> convert_to_array(int L, vector<int> A) {
    vector<int> res;
//    for (auto x : A) cerr<<x<<" "; cerr<<endl;
    for (int i = 0; i < L; i+=bit_size + 1) {
        ll tmp = 0;
        FOR(j, i, i + bit_size) tmp = tmp * 2 + A[j];
//        exit(0);
        vector<int> arr = convert_to_array(tmp);
        for (auto x : arr) res.push_back(x);
    }
    return res;
}
 
void Bruno(int n, int L, vector<int> A) {
    A = convert_to_array(L, A);
    while ((int)A.size() > n) A.pop_back();
//    cout<<"new data : ";
//    for (auto x : A) cout<<x<<" "; cout<<"\n";
    if (*mxx(all(A)) == 0) {
        REP(i, 0, n) Remove(i);
        return ;
    }
    int pos = 0;
    REP(i, 0, n)
        if (A[i] == 1) {
            pos = i;
            break;
        }
    REP(i, 0, pos) Remove(i);
    if (pos == n - 1) {
        Remove(pos);
        return ;
    }
    int i = pos;
    while (i < n) {
        if (i == n - 1) break;
        int j = i + 1;
        while (j < n && A[j] == 0) j++;
        if (j >= n) {
            REP(k, i + 1, n) Remove(k);
            i = n - 1;
            break;
        }
        FORD(k, j - 1, i + 1) Remove(k);
        if (j > pos) Remove(j);
        i = j;
    }
    if (pos != i) Remove(pos);
}

Compilation message

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:78:10: warning: unused variable 'kt' [-Wunused-variable]
   78 |     bool kt = false;
      |          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 784 KB Output is correct
2 Correct 0 ms 800 KB Output is correct
3 Correct 0 ms 788 KB Output is correct
4 Correct 0 ms 800 KB Output is correct
5 Correct 0 ms 800 KB Output is correct
6 Correct 0 ms 800 KB Output is correct
7 Correct 0 ms 800 KB Output is correct
8 Correct 0 ms 800 KB Output is correct
9 Correct 0 ms 800 KB Output is correct
10 Correct 0 ms 788 KB Output is correct
11 Correct 0 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 43 ms 9128 KB Partially correct
2 Partially correct 43 ms 9044 KB Partially correct
3 Partially correct 44 ms 9136 KB Partially correct
4 Partially correct 46 ms 9336 KB Partially correct
5 Partially correct 43 ms 9140 KB Partially correct
6 Partially correct 47 ms 9140 KB Partially correct
7 Partially correct 43 ms 8948 KB Partially correct
8 Partially correct 43 ms 9088 KB Partially correct
9 Partially correct 43 ms 9128 KB Partially correct
10 Partially correct 43 ms 9240 KB Partially correct
11 Partially correct 44 ms 9220 KB Partially correct
12 Incorrect 44 ms 9224 KB Wrong Answer [6]
13 Halted 0 ms 0 KB -