Submission #1034741

#TimeUsernameProblemLanguageResultExecution timeMemory
1034741DeathIsAweCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { vector<char> letters; string p = ''; string ptemp = ''; int temp = press("AB"); if (temp == 2) { p += 'A'; } else if (temp == 1) { temp = press("A"); if (temp == 1) { p += 'A'; } else { p += 'B'; } } else { temp = press("X"); if (temp == 1) { p += 'X'; } else { p += 'Y'; } } if ('A' != p[0]) { letters.push_back('A'); } if ('B' != p[0]) { letters.push_back('B'); } if ('X' != p[0]) { letters.push_back('X'); } if ('Y' != p[0]) { letters.push_back('Y'); } int count = 0; while (p.size() < n-1) { count += 1; ptemp = ''; count = 0; for (int i=0;i<3;i++) { ptemp += p; ptemp += letters[0]; ptemp += letters[i]; } ptemp += p; ptemp += letters[1]; temp=press(ptemp); if (temp == p.size()) { p += letters[2]; } else if (temp == p.size()+1) { p += letters[1]; } else { p += letters[0]; } } if (count > 2*n) { count = 1/0; } ptemp = p + letters[0]; if (press(ptemp) == n) { p += letters[0]; return p; } else { ptemp = p + letters[1]; if (press(ptemp) == n) { p += letters[1]; return p; } else { p += letters[2]; return p; } } }

Compilation message (stderr)

combo.cpp:7:14: error: empty character constant
    7 |   string p = '';
      |              ^~
combo.cpp:8:18: error: empty character constant
    8 |   string ptemp = '';
      |                  ^~
combo.cpp:45:13: error: empty character constant
   45 |     ptemp = '';
      |             ^~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:7:14: error: conversion from 'char' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
    7 |   string p = '';
      |              ^~
combo.cpp:8:18: error: conversion from 'char' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
    8 |   string ptemp = '';
      |                  ^~
combo.cpp:43:19: 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 (p.size() < n-1) {
      |          ~~~~~~~~~^~~~~
combo.cpp:56:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     if (temp == p.size()) {
      |         ~~~~~^~~~~~~~~~~
combo.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     } else  if (temp == p.size()+1) {
      |                 ~~~~~^~~~~~~~~~~~~
combo.cpp:65:14: warning: division by zero [-Wdiv-by-zero]
   65 |     count = 1/0;
      |             ~^~