제출 #1071873

#제출 시각아이디문제언어결과실행 시간메모리
1071873Rigobertus콤보 (IOI18_combo)C++17
10 / 100
41 ms1128 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; string guess_sequence(int n) { string c[4] = {"A", "B", "X", "Y"}; string s = ""; set<int> vis; for (int i = 0; i < 4; i++) { vis.insert(i); } int j; for (int i = 0; i < 4; i++) { if (i == 3 || press(c[i])) { s = c[i]; j = i; vis.erase(i); break; } } while (s.size() < n) { int last = *vis.rbegin(); int k; for (int i = 0; i < 4; i++) { k = i; if (!vis.count(i)) { if (i != j) { vis.insert(i); } continue; } if (i == last) { s += c[i]; break; } string p = s + c[i] + c[i]; int x = press(p); if (x == p.size()) { s = p; break; } else if (x == p.size() - 1) { s += c[i]; vis.erase(i); break; } } for (int i = k+1; i<4; i++) vis.insert(i); } return s;}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:11:360: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   11 | string guess_sequence(int n) {    string c[4] = {"A", "B", "X", "Y"};    string s = "";    set<int> vis;    for (int i = 0; i < 4; i++) {        vis.insert(i);    }    int j;    for (int i = 0; i < 4; i++) {        if (i == 3 || press(c[i])) {            s = c[i];            j = i;            vis.erase(i);            break;        }    }    while (s.size() < n) {        int last = *vis.rbegin();        int k;        for (int i = 0; i < 4; i++) {            k = i;            if (!vis.count(i)) {                if (i != j) {                    vis.insert(i);                }                continue;            }            if (i == last) {                s += c[i];                break;            }            string p = s + c[i] + c[i];            int x = press(p);            if (x == p.size()) {                s = p;                break;            }            else if (x == p.size() - 1) {                s += c[i];                vis.erase(i);                break;            }        }        for (int i = k+1; i<4; i++) vis.insert(i);    }    return s;}
      |                                                                                                                                                                                                                                                                                                                                                               ~~~~~~~~~^~~
combo.cpp:11:793: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | string guess_sequence(int n) {    string c[4] = {"A", "B", "X", "Y"};    string s = "";    set<int> vis;    for (int i = 0; i < 4; i++) {        vis.insert(i);    }    int j;    for (int i = 0; i < 4; i++) {        if (i == 3 || press(c[i])) {            s = c[i];            j = i;            vis.erase(i);            break;        }    }    while (s.size() < n) {        int last = *vis.rbegin();        int k;        for (int i = 0; i < 4; i++) {            k = i;            if (!vis.count(i)) {                if (i != j) {                    vis.insert(i);                }                continue;            }            if (i == last) {                s += c[i];                break;            }            string p = s + c[i] + c[i];            int x = press(p);            if (x == p.size()) {                s = p;                break;            }            else if (x == p.size() - 1) {                s += c[i];                vis.erase(i);                break;            }        }        for (int i = k+1; i<4; i++) vis.insert(i);    }    return s;}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ~~^~~~~~~~~~~
combo.cpp:11:887: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | string guess_sequence(int n) {    string c[4] = {"A", "B", "X", "Y"};    string s = "";    set<int> vis;    for (int i = 0; i < 4; i++) {        vis.insert(i);    }    int j;    for (int i = 0; i < 4; i++) {        if (i == 3 || press(c[i])) {            s = c[i];            j = i;            vis.erase(i);            break;        }    }    while (s.size() < n) {        int last = *vis.rbegin();        int k;        for (int i = 0; i < 4; i++) {            k = i;            if (!vis.count(i)) {                if (i != j) {                    vis.insert(i);                }                continue;            }            if (i == last) {                s += c[i];                break;            }            string p = s + c[i] + c[i];            int x = press(p);            if (x == p.size()) {                s = p;                break;            }            else if (x == p.size() - 1) {                s += c[i];                vis.erase(i);                break;            }        }        for (int i = k+1; i<4; i++) vis.insert(i);    }    return s;}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ~~^~~~~~~~~~~~~~~
combo.cpp:11:516: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   11 | string guess_sequence(int n) {    string c[4] = {"A", "B", "X", "Y"};    string s = "";    set<int> vis;    for (int i = 0; i < 4; i++) {        vis.insert(i);    }    int j;    for (int i = 0; i < 4; i++) {        if (i == 3 || press(c[i])) {            s = c[i];            j = i;            vis.erase(i);            break;        }    }    while (s.size() < n) {        int last = *vis.rbegin();        int k;        for (int i = 0; i < 4; i++) {            k = i;            if (!vis.count(i)) {                if (i != j) {                    vis.insert(i);                }                continue;            }            if (i == last) {                s += c[i];                break;            }            string p = s + c[i] + c[i];            int x = press(p);            if (x == p.size()) {                s = p;                break;            }            else if (x == p.size() - 1) {                s += c[i];                vis.erase(i);                break;            }        }        for (int i = k+1; i<4; i++) vis.insert(i);    }    return s;}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...