제출 #1044232

#제출 시각아이디문제언어결과실행 시간메모리
1044232alex_2008COVID tests (CEOI24_covid)C++14
컴파일 에러
0 ms0 KiB
#include <cmath> #include <algorithm> #include <vector> #include <map> #include <queue> #include <stack> typedef long long ll; using namespace std; const int N = 2e5 + 10; int n, t; long double p; bool ch(int l, int r) { string s = string(n, '0'); for (int i = l - 1; i < r; i++) { s[i] = '1'; } cout << "Q " << s << endl; char x; cin >> x; if (x == 'P') return true; return false; } int main() { cin >> n >> p >> t; if (t == 1) { string ans = string(n, '0'); for (int i = 1; i <= n; i++) { cout << "Q "; string s = string(n, '0'); s[i - 1] = '1'; cout << s << endl; char x; cin >> x; if (x == 'P') ans[i - 1] = '1'; } cout << "A " << ans << endl; char x; cin >> x; return 0; } if (p <= 0.01) { while (t--) { string answ = string(n, '0'); int last = 0; while (1) { if (!ch(last + 1, n)) { break; } int l = last + 1, r = n - 1, ans = last; while (l <= r) { int mid = (l + r) / 2; if (!ch(last + 1, mid)) { ans = mid; l = mid + 1; } else r = mid - 1; } answ[ans] = '1'; last = ans + 1; } cout << "A " << answ << endl; char x; cin >> x; } return 0; } else { int block; if (p == 0.011546) block = n; if (p == 0.028545) block = 511; if (p == 0.039856) block = 255; if (p == 0.068648) block = 179; if (p == 0.104571) block = 127; if (p == 0.2) block = 63; while (t--) { string answ = string(n, '0'); int last = 0; while (last < n) { int l = last + 1, r = min(n, last + block), ans = -1; while (l <= r) { int mid = (l + r) / 2; if (!ch(last + 1, mid)) { ans = mid; l = mid + 1; } else r = mid - 1; } if (ans == n) break; if (ans != -1) { answ[ans] = '1'; last = ans + 1; } else { answ[last] = '1'; last++; } } cout << "A " << answ << endl; char x; cin >> x; } return 0; } }

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

Main.cpp: In function 'bool ch(int, int)':
Main.cpp:13:2: error: 'string' was not declared in this scope
   13 |  string s = string(n, '0');
      |  ^~~~~~
Main.cpp:7:1: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
    6 | #include <stack>
  +++ |+#include <string>
    7 | typedef long long ll;
Main.cpp:15:3: error: 's' was not declared in this scope
   15 |   s[i] = '1';
      |   ^
Main.cpp:17:2: error: 'cout' was not declared in this scope
   17 |  cout << "Q " << s << endl;
      |  ^~~~
Main.cpp:7:1: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    6 | #include <stack>
  +++ |+#include <iostream>
    7 | typedef long long ll;
Main.cpp:17:18: error: 's' was not declared in this scope
   17 |  cout << "Q " << s << endl;
      |                  ^
Main.cpp:17:23: error: 'endl' was not declared in this scope
   17 |  cout << "Q " << s << endl;
      |                       ^~~~
Main.cpp:7:1: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?
    6 | #include <stack>
  +++ |+#include <ostream>
    7 | typedef long long ll;
Main.cpp:19:2: error: 'cin' was not declared in this scope
   19 |  cin >> x;
      |  ^~~
Main.cpp:19:2: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
Main.cpp: In function 'int main()':
Main.cpp:24:2: error: 'cin' was not declared in this scope
   24 |  cin >> n >> p >> t;
      |  ^~~
Main.cpp:24:2: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
Main.cpp:26:3: error: 'string' was not declared in this scope
   26 |   string ans = string(n, '0');
      |   ^~~~~~
Main.cpp:26:3: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
Main.cpp:28:4: error: 'cout' was not declared in this scope
   28 |    cout << "Q ";
      |    ^~~~
Main.cpp:28:4: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
Main.cpp:29:10: error: expected ';' before 's'
   29 |    string s = string(n, '0');
      |          ^~
      |          ;
Main.cpp:30:4: error: 's' was not declared in this scope
   30 |    s[i - 1] = '1';
      |    ^
Main.cpp:31:17: error: 'endl' was not declared in this scope
   31 |    cout << s << endl;
      |                 ^~~~
Main.cpp:31:17: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?
Main.cpp:34:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |    if (x == 'P') ans[i - 1] = '1';
      |                  ^~~
      |                  abs
Main.cpp:36:3: error: 'cout' was not declared in this scope
   36 |   cout << "A " << ans << endl;
      |   ^~~~
Main.cpp:36:3: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
Main.cpp:36:19: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |   cout << "A " << ans << endl;
      |                   ^~~
      |                   abs
Main.cpp:36:26: error: 'endl' was not declared in this scope
   36 |   cout << "A " << ans << endl;
      |                          ^~~~
Main.cpp:36:26: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?
Main.cpp:43:4: error: 'string' was not declared in this scope
   43 |    string answ = string(n, '0');
      |    ^~~~~~
Main.cpp:43:4: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
Main.cpp:58:5: error: 'answ' was not declared in this scope; did you mean 'ans'?
   58 |     answ[ans] = '1';
      |     ^~~~
      |     ans
Main.cpp:61:4: error: 'cout' was not declared in this scope
   61 |    cout << "A " << answ << endl;
      |    ^~~~
Main.cpp:61:4: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
Main.cpp:61:20: error: 'answ' was not declared in this scope
   61 |    cout << "A " << answ << endl;
      |                    ^~~~
Main.cpp:61:28: error: 'endl' was not declared in this scope
   61 |    cout << "A " << answ << endl;
      |                            ^~~~
Main.cpp:61:28: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?
Main.cpp:76:4: error: 'string' was not declared in this scope
   76 |    string answ = string(n, '0');
      |    ^~~~~~
Main.cpp:76:4: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
Main.cpp:90:6: error: 'answ' was not declared in this scope; did you mean 'ans'?
   90 |      answ[ans] = '1';
      |      ^~~~
      |      ans
Main.cpp:94:6: error: 'answ' was not declared in this scope; did you mean 'ans'?
   94 |      answ[last] = '1';
      |      ^~~~
      |      ans
Main.cpp:98:4: error: 'cout' was not declared in this scope
   98 |    cout << "A " << answ << endl;
      |    ^~~~
Main.cpp:98:4: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
Main.cpp:98:20: error: 'answ' was not declared in this scope
   98 |    cout << "A " << answ << endl;
      |                    ^~~~
Main.cpp:98:28: error: 'endl' was not declared in this scope
   98 |    cout << "A " << answ << endl;
      |                            ^~~~
Main.cpp:98:28: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?