Submission #1297211

#TimeUsernameProblemLanguageResultExecution timeMemory
1297211nguyenkhangninh99Broken Device (JOI17_broken_device)C++20
Compilation error
0 ms0 KiB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

void Anna(int n, long long x, int k, int p[]){
    vector<int> bad(n), res(n);
    for(int i = 0; i < k; i++) bad[p[i]] 1;
    for(int i = 0; i < n; i += 3){
        if(bad[i] + bad[i + 1] + bad[i + 2] >= 2) continue;
        if(bad[i] + bad[i + 1] + bad[i + 2] == 1){
            if(x % 2 == 0){
                if(bad[i]) res[i + 2] = 1;
                else if(bad[i + 1]) res[i + 2] = 1;
                else res[i] = res[i + 1] = 1;
            }else{
                if(bad[i]){
                    if(x % 4 == 1) res[i + 1] = 1;
                    else res[i + 1] = res[i + 2] = 1;
                    x /= 2;
                }
                if(bad[i + 1]) res[i] = 1;
                if(bad[i + 2]) res[i] = 1;
            }
            x /= 2;
        }else{
            res[i] = res[i + 1] = res[i + 2] = 1;
            if(x % 4 == 1) res[i] = res[i + 2] = 0;
            else if(x % 4 == 2) res[i + 1] = 0;
            else if(x % 4 == 3) res[i] = 0;
            x /= 4;
        }
    }
    for(int i = 0; i < n; i++) Set(i, res[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

void update(int &res, int t){
    if(t == 1) res *= 2;
    if(t == 2) res = res * 4 + 1;
    if(t == 3) res = res * 4 + 3;
    if(t == 4) res = res * 2 + 1;
    if(t == 5) res = res * 4 + 2;
    if(t == 6) res *= 2;
    if(t == 7) res *= 4
}

long long Bruno(int n, int a[]){
    long long res = 0;
    for(int i = n - 3; i >= 0; i -= 3) update(res, 4 * a[i] + 2 * a[i + 1] + a[i + 2]);
    return res;
}

Compilation message (stderr)

# 1번째 컴파일 단계

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:7:41: error: expected ';' before numeric constant
    7 |     for(int i = 0; i < k; i++) bad[p[i]] 1;
      |                                         ^~
      |                                         ;
Anna.cpp:7:40: warning: ignoring return value of 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
    7 |     for(int i = 0; i < k; i++) bad[p[i]] 1;
      |                                        ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from Anna.cpp:2:
/usr/include/c++/13/bits/stl_vector.h:1126:7: note: declared here
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~