Submission #530640

# Submission time Handle Problem Language Result Execution time Memory
530640 2022-02-26T05:44:12 Z byunjaewoo Broken Device (JOI17_broken_device) C++17
100 / 100
39 ms 2416 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

bool chk[155];

void MySet(int p, int a, int b, int c) {
    Set(p, a); Set(p+1, b); Set(p+2, c);
}

void Anna( int N, long long X, int K, int P[] ){
    fill(chk, chk+151, 0);
    for(int i=0; i<K; i++) chk[P[i]]=1;
    vector<bool> V;
    while(X) {
        V.push_back(X%2);
        X/=2;
    }
    for(int i=0, p=0; i<150; i+=3) {
        if(p>=V.size()) {
            MySet(i, 0, 0, 0);
            continue;
        }
        if(chk[i]+chk[i+1]+chk[i+2]==0) {
            if(p==V.size()-1) V.push_back(0);
            if(V[p]==0 && V[p+1]==0) MySet(i, 1, 0, 0);
            else if(V[p]==0 && V[p+1]==1) MySet(i, 1, 0, 1);
            else if(V[p]==1 && V[p+1]==0) MySet(i, 0, 1, 1);
            else MySet(i, 1, 1, 1);
            p+=2;
        }
        else if(chk[i]+chk[i+1]+chk[i+2]==1) {
            if(chk[i]) {
                if(V[p]==0) MySet(i, 0, 1, 0);
                else MySet(i, 0, 0, 1);
                p++;
            }
            else if(chk[i+1]) {
                if(V[p]==0) {
                    if(p==V.size()-1) V.push_back(0);
                    if(V[p+1]==0) MySet(i, 1, 0, 0);
                    else MySet(i, 1, 0, 1);
                    p+=2;
                }
                else {MySet(i, 0, 0, 1); p++;}
            }
            else {
                if(V[p]==0) MySet(i, 0, 1, 0);
                else MySet(i, 1, 1, 0);
                p++;
            }
        }
        else MySet(i, 0, 0, 0);
    }
}
#include <bits/stdc++.h>
using namespace std;
#include "Brunolib.h"

long long Bruno( int N, int A[] ){
    long long x=0;
    for(int i=N-1; i>=0; i-=3) {
        int tmp=A[i-2]*4+A[i-1]*2+A[i];
        if(tmp==1) x=x*2+1;
        if(tmp==2) x*=2;
        if(tmp==3) x=x*4+1;
        if(tmp==4) x*=4;
        if(tmp==5) x=x*4+2;
        if(tmp==6) x=x*2+1;
        if(tmp==7) x=x*4+3;
    }
    return x;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         if(p>=V.size()) {
      |            ~^~~~~~~~~~
Anna.cpp:25:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             if(p==V.size()-1) V.push_back(0);
      |                ~^~~~~~~~~~~~
Anna.cpp:40:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |                     if(p==V.size()-1) V.push_back(0);
      |                        ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2352 KB Output is correct - L* = 40
2 Correct 28 ms 2324 KB Output is correct - L* = 40
3 Correct 28 ms 2224 KB Output is correct - L* = 40
4 Correct 28 ms 2392 KB Output is correct - L* = 40
5 Correct 30 ms 2288 KB Output is correct - L* = 40
6 Correct 27 ms 2224 KB Output is correct - L* = 40
7 Correct 30 ms 2204 KB Output is correct - L* = 40
8 Correct 30 ms 2284 KB Output is correct - L* = 40
9 Correct 28 ms 2196 KB Output is correct - L* = 40
10 Correct 28 ms 2224 KB Output is correct - L* = 40
11 Correct 28 ms 2248 KB Output is correct - L* = 40
12 Correct 35 ms 2304 KB Output is correct - L* = 40
13 Correct 31 ms 2416 KB Output is correct - L* = 40
14 Correct 28 ms 2292 KB Output is correct - L* = 40
15 Correct 35 ms 2352 KB Output is correct - L* = 40
16 Correct 27 ms 2316 KB Output is correct - L* = 40
17 Correct 28 ms 2360 KB Output is correct - L* = 40
18 Correct 30 ms 2244 KB Output is correct - L* = 40
19 Correct 30 ms 2156 KB Output is correct - L* = 40
20 Correct 29 ms 2320 KB Output is correct - L* = 40
21 Correct 28 ms 2288 KB Output is correct - L* = 40
22 Correct 30 ms 2220 KB Output is correct - L* = 40
23 Correct 28 ms 2280 KB Output is correct - L* = 40
24 Correct 28 ms 2308 KB Output is correct - L* = 40
25 Correct 31 ms 2192 KB Output is correct - L* = 40
26 Correct 39 ms 2288 KB Output is correct - L* = 40
27 Correct 31 ms 2252 KB Output is correct - L* = 40
28 Correct 34 ms 2336 KB Output is correct - L* = 40
29 Correct 28 ms 2380 KB Output is correct - L* = 40
30 Correct 28 ms 2264 KB Output is correct - L* = 40
31 Correct 28 ms 2312 KB Output is correct - L* = 40
32 Correct 28 ms 2196 KB Output is correct - L* = 40
33 Correct 38 ms 2260 KB Output is correct - L* = 40
34 Correct 30 ms 2204 KB Output is correct - L* = 40
35 Correct 28 ms 2292 KB Output is correct - L* = 40
36 Correct 31 ms 2204 KB Output is correct - L* = 40
37 Correct 27 ms 2240 KB Output is correct - L* = 40
38 Correct 28 ms 2204 KB Output is correct - L* = 40
39 Correct 28 ms 2304 KB Output is correct - L* = 40
40 Correct 29 ms 2280 KB Output is correct - L* = 40