제출 #1329956

#제출 시각아이디문제언어결과실행 시간메모리
1329956SulA레지스터 (IOI21_registers)C++20
컴파일 에러
0 ms0 KiB
#include "registers.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

void dup(int r) {
    for (int i = 0; i < 2; i++) {
        append_left(67, r, 1);
        append_or(r, r, 67);
    }
}

void construct_instructions(int s, int n, int k, int q) {
    if (k == 1) {
        append_right(67, 0, 1);
        append_and(0, 0, 67);
        return;
    }
    vector<bool> bits(2000);
    bits[0] = 1;
    append_store(99, bits);
    bits[1] = 1;
    append_store(98, bits);

    append_right(1, 0, 1);   // x1 y0 y1 ...
    append_right(2, 1, 1);   // y0 y1 ...
    append_right(3, 2, 1);   // y1 ...
    append_and (0, 0, 98); // x0 x1 ...
    append_and(1, 1, 99);
    append_not (4, 0);         // ~x0 ~x1
    append_not (5, 1);         // ~x1
    append_and (6, 3, 5);   // x1 < y1
    append_xor (7, 3, 5);   // x1 = y1
    append_and (8, 2, 4);   // x0 < y0
    append_and (9, 7, 8);   // (x1 = y1) & (x0 < y0)
    append_or  (10, 6, 9);  // x < y
    append_and (10, 10, 99);
    dup(10);                      // dup r[10][0] everywhere
    append_not (11, 10);       // x ≥ y
    dup(11);
    append_and (12, 0, 10);
    append_and(13, 2, 11);
    append_add(0, 12, 13);
}

//int main() {
//}

컴파일 시 표준 에러 (stderr) 메시지

registers.cpp:9:6: error: ambiguating new declaration of 'void dup(int)'
    9 | void dup(int r) {
      |      ^~~
In file included from /usr/include/c++/13/bits/atomic_wait.h:45,
                 from /usr/include/c++/13/bits/atomic_base.h:42,
                 from /usr/include/c++/13/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/13/memory:81,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56,
                 from registers.cpp:2:
/usr/include/unistd.h:552:12: note: old declaration 'int dup(int)'
  552 | extern int dup (int __fd) __THROW __wur;
      |            ^~~
registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:41:8: warning: ignoring return value of 'int dup(int)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     dup(10);                      // dup r[10][0] everywhere
      |     ~~~^~~~
registers.cpp:43:8: warning: ignoring return value of 'int dup(int)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     dup(11);
      |     ~~~^~~~