Submission #907445

# Submission time Handle Problem Language Result Execution time Memory
907445 2024-01-15T15:27:14 Z andrey27_sm Broken Device (JOI17_broken_device) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <Annalib.h>
using namespace std;
pair<int,int> mask_to_num(int m){
    if(m == 7) return {3,2};
    if(m == 6) return {1,2};
    if(m == 5) return {2,2};
    if(m == 4) return {1,1};
    if(m == 3) return {1,1};
    if(m == 2) return {0,2};
    if(m == 1) return {0,1};
    if(m == 0) return {0,0};
}
int num_to_mask(int n){
    for(int i = 1;i < 7;i++){
        if(mask_to_num(m).second == 2 and mask_to_num(m).first == n) return i;
    }
}
void Anna( int N, long long X, int K, int P[] ){
    vector<int> L(N,-2);
    stack<int> B;
    while(X) B.push(X%2), X/=2;
    while(B.size()%2 != 0) B.push(0);
    for(int i = 0;i < K;i++) L[P[i]] = -1;
    for(int i = 0;i < N;i+=3){
        if(L[i]+L[i+1]+L[i+2] > -5 or B.empty()) {
            Set(i,0);
            Set(i+1,0);
            Set(i+2,0);
            continue;   
        }
        if(L[i]+L[i+1]+L[i+2] == -6){
            if(B.empty()) B.push(0);
            int a = B.top();
            B.pop();
            if(B.empty()) B.push(0);
            int b = B.top();
            B.pop();
            int c = num_to_mask(a*2+b);
            Set(i,c/4);
            Set(i+1,(c/2)%2);
            Set(i+2,c%2);
        }
        else{
            if(B.empty()) B.push(0);
            int a = B.top();
            B.pop();
            if(a == 1 and L[i] == -2){
                Set(i,1);
                Set(i+1,0);
                Set(i+2,0);
            }
            else if(a == 1){
                Set(i,0);
                Set(i+1,1);
                Set(i+2,1);
            }
            else if(a == 0 and L[i+2] == -2){
                Set(i,0);
                Set(i+1,0);
                Set(i+2,1);
            }
            else{
                if(B.empty()) B.push(0);
                int b = B.top();
                B.pop();
                Set(i,b);
                Set(i+1,1);
                Set(i+2,0);
            }
        }
    }
}
#include <bits/stdc++.h>
#include <Brunolib.h>
using namespace std;
pair<int,int> mask_to_num(int m){
    if(m == 7) return {3,2};
    if(m == 6) return {1,2};
    if(m == 5) return {2,2};
    if(m == 4) return {1,1};
    if(m == 3) return {1,1};
    if(m == 2) return {0,2};
    if(m == 1) return {0,1};
    if(m == 0) return {0,0};
}
int num_to_mask(int n){
    for(int i = 1;i < 7;i++){
        if(mask_to_num(m).second == 2 and mask_to_num(m).first == n) return i;
    }
}

long long Bruno( int N, int A[] ){
    long long X = 0;
    int cnt = 0;
    for(int i = 0;i < N;i+=3){
        pair<int,int> a = mask_to_num(A[i]*4+A[i+1]*2+A[i+2]);
        if(a.second == 0) continue;
        if(a.second == 1 and cnt < 60){
            cnt++;
            X = X<<1|a.first;
        }
        if(a.second and cnt < 59){
            cnt+=2;
            X = X<<2|a.first;
        }
        else if(a.second and cnt < 60){
            cnt+=1;
            X = X<<1|(a.first>>1);
        }
    }
    return X;
}

Compilation message

Anna.cpp: In function 'int num_to_mask(int)':
Anna.cpp:16:24: error: 'm' was not declared in this scope
   16 |         if(mask_to_num(m).second == 2 and mask_to_num(m).first == n) return i;
      |                        ^
Anna.cpp: In function 'std::pair<int, int> mask_to_num(int)':
Anna.cpp:13:1: warning: control reaches end of non-void function [-Wreturn-type]
   13 | }
      | ^
Anna.cpp: In function 'int num_to_mask(int)':
Anna.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
   18 | }
      | ^

Bruno.cpp: In function 'int num_to_mask(int)':
Bruno.cpp:16:24: error: 'm' was not declared in this scope
   16 |         if(mask_to_num(m).second == 2 and mask_to_num(m).first == n) return i;
      |                        ^
Bruno.cpp: In function 'std::pair<int, int> mask_to_num(int)':
Bruno.cpp:13:1: warning: control reaches end of non-void function [-Wreturn-type]
   13 | }
      | ^
Bruno.cpp: In function 'int num_to_mask(int)':
Bruno.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
   18 | }
      | ^