제출 #434390

#제출 시각아이디문제언어결과실행 시간메모리
434390bipartite_matching콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define forint(i, N) for (int i = 0; i < (N); i++) using namespace std; int press(string p); string guess_sequence(int N) { string ans = ""; vector<char> v; if (press("AB") == 1) { if (press("A") == 1) { ans += 'A'; v = {'B', 'X', 'Y'}; } else { ans += 'B'; v = {'A', 'X', 'Y'}; } } else { if (press("X") == 1) { ans += 'X'; v = {'A', 'B', 'Y'}; } else { ans += 'Y'; v = {'A', 'B', 'X'}; } } /*if (press("A") == 1) { ans += 'A'; v = {'B', 'X', 'Y'}; } else if (press("B") == 1) { ans += 'B'; v = {'A', 'X', 'Y'}; } else if (press("X") == 1) { ans += 'X'; v = {'A', 'B', 'Y'}; } else { ans += 'Y'; v = {'A', 'B', 'X'}; }*/ if (N == 1) { return ans; } //int pos = 1; for (int i = 1; i < N - 1; i++) { int tmp = press(ans + v[0] + ans + v[1] + v[0] + ans + v[1] + v[1] + ans + v[1] + v[2]); if (tmp == i + 1) { ans += v[0]; } else if (tmp == i + 2) { ans += v[1]; } else { ans += v[2]; } } if (press(ans + v[0]) == N) { ans += v[0]; } else if (press(ans + v[1]) == N) { ans += v[1]; } else { ans += v[2]; } return ans; } string test = "A"; int press(string p) { int ret = 0; queue<int> q; forint(i, p.length()) { if (p[i] == test[0]) { q.push(i); } } if (!q.empty()) { ret++; } else { return 0; } while (!q.empty()) { int a = q.size(); forint(i, a) { int tmp = q.front(); q.pop(); if (tmp + 1 < p.length() && p[tmp + 1] == test[ret]) { q.push(tmp + 1); } } if (!q.empty()) { ret++; } } return ret; }

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

combo.cpp: In function 'int press(std::string)':
combo.cpp:3:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define forint(i, N) for (int i = 0; i < (N); i++)
      |                                        ^
combo.cpp:90:2: note: in expansion of macro 'forint'
   90 |  forint(i, p.length()) {
      |  ^~~~~~
combo.cpp:108:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  108 |    if (tmp + 1 < p.length() && p[tmp + 1] == test[ret]) {
      |        ~~~~~~~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/cc9NbY6c.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/ccxjRHaa.o:combo.cpp:(.text+0x130): first defined here
collect2: error: ld returned 1 exit status