답안 #1019953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1019953 2024-07-11T11:15:16 Z Unforgettablepl Broken Device 2 (JOI22_device2) C++17
25 / 100
387 ms 28244 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

const int M = 2000;

namespace {

vector<int> lookup = {
    0,
    1,
    3,
    7,
    15,
    31,
};

tuple<int,int,int,int> generate(long long x){
    long long curr = 0;
    for(int len=64;len<=M;len++){
        if(curr+36*(2*(len-2)-123)-1<x){
            curr+=36*(2*(len-2)-123);
            continue;
        }
        for(int turnedon=124;turnedon<=2*len-4;turnedon++){
            for(int starting=0;starting<6;starting++){
                for(int ending=0;ending<6;ending++){
                    if(curr++==x)return {len,turnedon,lookup[starting],lookup[ending]};
                }
            }
        }
    }
    assert(false);
}

}

int Declare() {return M;}

pair<vector<int>, vector<int>> Anna(long long A) {
    auto [len,ones,starting,ending] = generate(A);
    vector<int> a(len,0),b(len,0);
    for(int i=0;i<starting;i++){
        a[i]=b[i]=1;
        ones-=2;
    }
    for(int i=0;i<ending;i++){
        a[len-i-1]=b[len-i-1]=1;
        ones-=2;
    }
    for(int i=starting+1;i<len;i++){
        if(ones){a[i]=1;ones--;}
        if(ones){b[i]=1;ones--;}
    }
    return {a,b};
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;

const int M = 2000;

namespace {


long long generate(int tarlen,int taron,int tarstarting,int tarending){
    long long curr = 0;
    for(int len=64;len<=M;len++){
        if(len!=tarlen){
            curr+=36*(2*(len-2)-123);
            continue;
        }
        for(int turnedon=124;turnedon<=2*len-4;turnedon++){
            if(turnedon!=taron){curr+=36;continue;}
            for(int starting=0;starting<6;starting++){
                if(starting!=tarstarting){curr+=6;continue;}
                for(int ending=0;ending<6;ending++){
                    if(ending==tarending)return curr;
                    curr++;
                }
            }
        }
    }
    assert(false);
}

}

long long Bruno(vector<int> u) {
    int len = u.size()/2;
    int ones = 0;
    for(int&i:u)ones+=i;
    int starting = 0;
    for(int&i:u){
        if(i) starting++;
        else break;
    }
    reverse(u.begin(),u.end());
    int ending = 0;
    for(int&i:u){
        if(i) ending++;
        else break;
    }
    if(0<=starting and starting<=0)starting=0;
    else if(1<=starting and starting<=2)starting=1;
    else if(3<=starting and starting<=6)starting=2;
    else if(7<=starting and starting<=14)starting=3;
    else if(15<=starting and starting<=30)starting=4;
    else if(31<=starting and starting<=62)starting=5;
    if(0<=ending and ending<=0)ending=0;
    else if(1<=ending and ending<=2)ending=1;
    else if(3<=ending and ending<=6)ending=2;
    else if(7<=ending and ending<=14)ending=3;
    else if(15<=ending and ending<=30)ending=4;
    else if(31<=ending and ending<=62)ending=5;
    return generate(len,ones,starting,ending);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 784 KB Output is correct
2 Correct 15 ms 1904 KB Output is correct
3 Correct 16 ms 1848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 784 KB Output is correct
2 Correct 15 ms 1904 KB Output is correct
3 Correct 16 ms 1848 KB Output is correct
4 Correct 74 ms 5500 KB Output is correct
5 Correct 70 ms 5432 KB Output is correct
6 Correct 62 ms 5444 KB Output is correct
7 Correct 59 ms 5412 KB Output is correct
8 Correct 68 ms 5920 KB Output is correct
9 Correct 81 ms 6932 KB Output is correct
10 Correct 80 ms 7064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 784 KB Output is correct
2 Correct 15 ms 1904 KB Output is correct
3 Correct 16 ms 1848 KB Output is correct
4 Correct 74 ms 5500 KB Output is correct
5 Correct 70 ms 5432 KB Output is correct
6 Correct 62 ms 5444 KB Output is correct
7 Correct 59 ms 5412 KB Output is correct
8 Correct 68 ms 5920 KB Output is correct
9 Correct 81 ms 6932 KB Output is correct
10 Correct 80 ms 7064 KB Output is correct
11 Correct 90 ms 7596 KB Output is correct
12 Correct 100 ms 7604 KB Output is correct
13 Correct 84 ms 7388 KB Output is correct
14 Correct 93 ms 7584 KB Output is correct
15 Correct 103 ms 7552 KB Output is correct
16 Correct 150 ms 10208 KB Output is correct
17 Correct 109 ms 10032 KB Output is correct
18 Correct 79 ms 5828 KB Output is correct
19 Correct 69 ms 6104 KB Output is correct
20 Correct 74 ms 5792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 784 KB Output is correct
2 Correct 15 ms 1904 KB Output is correct
3 Correct 16 ms 1848 KB Output is correct
4 Correct 74 ms 5500 KB Output is correct
5 Correct 70 ms 5432 KB Output is correct
6 Correct 62 ms 5444 KB Output is correct
7 Correct 59 ms 5412 KB Output is correct
8 Correct 68 ms 5920 KB Output is correct
9 Correct 81 ms 6932 KB Output is correct
10 Correct 80 ms 7064 KB Output is correct
11 Correct 90 ms 7596 KB Output is correct
12 Correct 100 ms 7604 KB Output is correct
13 Correct 84 ms 7388 KB Output is correct
14 Correct 93 ms 7584 KB Output is correct
15 Correct 103 ms 7552 KB Output is correct
16 Correct 150 ms 10208 KB Output is correct
17 Correct 109 ms 10032 KB Output is correct
18 Correct 79 ms 5828 KB Output is correct
19 Correct 69 ms 6104 KB Output is correct
20 Correct 74 ms 5792 KB Output is correct
21 Correct 245 ms 19588 KB Output is correct
22 Correct 256 ms 19788 KB Output is correct
23 Correct 263 ms 19804 KB Output is correct
24 Correct 280 ms 19876 KB Output is correct
25 Correct 260 ms 19560 KB Output is correct
26 Correct 387 ms 28212 KB Output is correct
27 Correct 368 ms 28244 KB Output is correct
28 Correct 174 ms 13808 KB Output is correct
29 Correct 176 ms 14060 KB Output is correct
30 Correct 191 ms 15220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 784 KB Output is correct
2 Correct 15 ms 1904 KB Output is correct
3 Correct 16 ms 1848 KB Output is correct
4 Correct 74 ms 5500 KB Output is correct
5 Correct 70 ms 5432 KB Output is correct
6 Correct 62 ms 5444 KB Output is correct
7 Correct 59 ms 5412 KB Output is correct
8 Correct 68 ms 5920 KB Output is correct
9 Correct 81 ms 6932 KB Output is correct
10 Correct 80 ms 7064 KB Output is correct
11 Correct 90 ms 7596 KB Output is correct
12 Correct 100 ms 7604 KB Output is correct
13 Correct 84 ms 7388 KB Output is correct
14 Correct 93 ms 7584 KB Output is correct
15 Correct 103 ms 7552 KB Output is correct
16 Correct 150 ms 10208 KB Output is correct
17 Correct 109 ms 10032 KB Output is correct
18 Correct 79 ms 5828 KB Output is correct
19 Correct 69 ms 6104 KB Output is correct
20 Correct 74 ms 5792 KB Output is correct
21 Correct 245 ms 19588 KB Output is correct
22 Correct 256 ms 19788 KB Output is correct
23 Correct 263 ms 19804 KB Output is correct
24 Correct 280 ms 19876 KB Output is correct
25 Correct 260 ms 19560 KB Output is correct
26 Correct 387 ms 28212 KB Output is correct
27 Correct 368 ms 28244 KB Output is correct
28 Correct 174 ms 13808 KB Output is correct
29 Correct 176 ms 14060 KB Output is correct
30 Correct 191 ms 15220 KB Output is correct
31 Runtime error 1 ms 600 KB Execution killed with signal 6
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -