Submission #464490

# Submission time Handle Problem Language Result Execution time Memory
464490 2021-08-13T10:01:24 Z fuad27 Password (RMI18_password) C++17
Compilation error
0 ms 0 KB
    #include <bits/stdc++.h>

    using namespace std;
    typedef long long ll;
    typedef long double ld;
    #define vii vector < pair < int, int >>
        #define vi vector < int >
        #define vl vector < long long >
        #define vll vector < pair < long long, long long >>
        #define mp make_pair
    #define pb push_back
    #define rep(i, a, b) for (int i = a; i <= b; i++)
        #define f first
    #define s second
    #define FIO ios_base::sync_with_stdio(0);
    cin.tie(0);
    #define start int tt;
    cin >> tt;
    rep(testcase, 1, tt)
    #define print(k) cout << "Case #" << testcase << ": " << k << "\n";
    #define endl "\n"
    #define DEBUG(k) cerr << k << "\n";
    int query(string str);
    int f[30];
    string guess(int n, int s) {
        string res;
        rep(i, 0, s - 1) {
            char c = 'a' + i;
            string q(n, c);
            f[i] = query(q);
        }
        int st = 0;
        rep(i, 0, s - 1) {
            if (f[i] > 0) {
                char c = i + 'a';
                rep(j, 1, f[i]) {
                    res += c;
                }
                st = i + 1;
                break;
            }
        }
        int curlen = res.length();
        rep(i, st, s - 1) {
            char c = i + 'a';
            string ch;
            ch += c;
            int pos = -1;
            string q;
            while (true) {
                if (f[i] == 0) break;
                if (pos == -1) {
                    q = ch + res;
                } else {
                    q = res.substr(0, pos + 1) + ch;
                    q += res.substr(pos + 1, curlen - pos - 1);
                }
                if (query(q) == curlen + 1) {
                    res = q;
                    curlen++;
                    pos++;
                    f[i]--;
                } else {
                    pos++;
                }
                if (pos >= curlen) break;
            }
        }
        return res;
    }

Compilation message

password.cpp:16:5: error: 'cin' does not name a type; did you mean 'sin'?
   16 |     cin.tie(0);
      |     ^~~
      |     sin
password.cpp:18:5: error: 'cin' does not name a type; did you mean 'sin'?
   18 |     cin >> tt;
      |     ^~~
      |     sin
password.cpp:12:26: error: expected unqualified-id before 'for'
   12 |     #define rep(i, a, b) for (int i = a; i <= b; i++)
      |                          ^~~
password.cpp:19:5: note: in expansion of macro 'rep'
   19 |     rep(testcase, 1, tt)
      |     ^~~
password.cpp:19:9: error: 'testcase' does not name a type
   19 |     rep(testcase, 1, tt)
      |         ^~~~~~~~
password.cpp:12:42: note: in definition of macro 'rep'
   12 |     #define rep(i, a, b) for (int i = a; i <= b; i++)
      |                                          ^
password.cpp:19:9: error: 'testcase' does not name a type
   19 |     rep(testcase, 1, tt)
      |         ^~~~~~~~
password.cpp:12:50: note: in definition of macro 'rep'
   12 |     #define rep(i, a, b) for (int i = a; i <= b; i++)
      |                                                  ^
password.cpp: In function 'std::string guess(int, int)':
password.cpp:30:20: error: 'query' was not declared in this scope
   30 |             f[i] = query(q);
      |                    ^~~~~
password.cpp:58:21: error: 'query' was not declared in this scope
   58 |                 if (query(q) == curlen + 1) {
      |                     ^~~~~