제출 #1072562

#제출 시각아이디문제언어결과실행 시간메모리
1072562Rigobertus콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <algorithm> #include <vector> #include <map> #include <set> #include <queue> #include <string> //#define int long long #include "combo.h" using namespace std; int press(string p) { cout << p << endl; int res; cin >> res; return res; } string guess_sequence(int n) { string c[4] = {"A", "B", "X", "Y"}; string s; if (press("AB")) { s = "B"; if (press("A")) { s = "A"; } } else { s = "X"; if (press("Y")) { s = "Y"; } } vector<int> a; for (int i = 0; i < 4; i++) { if (c[i] != s) { a.push_back(i); } } set<int> vis; for (int i = 0; i < 3; i++) { vis.insert(i); } while (s.size() < n) { int k; int last = *vis.rbegin(); for (int i = 0; i < 3; i++) { k = i; if (!vis.count(i)) { vis.insert(i); continue; } if (i == last) { s += c[a[i]]; for (int l = k+1; l < 3; l++) { vis.insert(l); } break; } string p = s + c[a[i]] + c[a[i]]; int x = press(p); if (x == s.size()) { continue; } for (int l = 0; l < 3; l++) { vis.insert(l); } if (x == p.size()) { s = p; } else if (x == s.size() + 1) { s += c[a[i]]; vis.erase(i); } break; } for (int i = k + 1; i < 3; i++) { vis.insert(i); } } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:43:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |     while (s.size() < n) {
      |            ~~~~~~~~~^~~
combo.cpp:61:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             if (x == s.size()) {
      |                 ~~^~~~~~~~~~~
combo.cpp:67:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             if (x == p.size()) {
      |                 ~~^~~~~~~~~~~
combo.cpp:70:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             else if (x == s.size() + 1) {
      |                      ~~^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cceSpHBX.o: in function `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x0): multiple definition of `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccJdsXfT.o:combo.cpp:(.text+0x290): first defined here
collect2: error: ld returned 1 exit status