Submission #773174

# Submission time Handle Problem Language Result Execution time Memory
773174 2023-07-04T16:05:30 Z aykhn Password (RMI18_password) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

// author: aykhn

using namespace std;

typedef long long ll;

#define s.length() (int)(s.length())

int query(string str);

string guess(int n, int s)
{
    string ans = "";
    int prev = 0;

    string x = "a";
    for (int i = 0; i < s; i++)
    {
        ans = x + ans;
        int X = query(ans);
        prev = max(X, prev);
        int sz = ans.length();
        if (!X) ans = ans.substr(1, sz - 1);

        for (int j = 1; j <= ans.length(); j++)
        {
            string asdasdasd = ans;
            string asd = ans.substr(0, j);
            string assd = "";
            int sz = ans.length();
            if (j != sz) assd = ans.substr(j, sz - j);
            ans = asd;
            ans += x;
            ans += assd;
            int y = query(ans);
            if (y <= prev)
            {
                ans = asdasdasd;
            }
            else prev = y;
            if (ans.length() == n) break;
        }
        if (ans.length() == n) break;

        x[0]++;
    }

    return ans;
}

Compilation message

password.cpp:9:9: warning: ISO C++11 requires whitespace after the macro name
    9 | #define s.length() (int)(s.length())
      |         ^
password.cpp:9:10: error: expected ',' or '...' before '.' token
    9 | #define s.length() (int)(s.length())
      |          ^
password.cpp:13:25: note: in expansion of macro 's'
   13 | string guess(int n, int s)
      |                         ^
password.cpp: In function 'std::string guess(int, int)':
password.cpp:9:10: error: expected primary-expression before '.' token
    9 | #define s.length() (int)(s.length())
      |          ^
password.cpp:19:25: note: in expansion of macro 's'
   19 |     for (int i = 0; i < s; i++)
      |                         ^
password.cpp:9:21: error: expected primary-expression before 'int'
    9 | #define s.length() (int)(s.length())
      |                     ^~~
password.cpp:19:25: note: in expansion of macro 's'
   19 |     for (int i = 0; i < s; i++)
      |                         ^
password.cpp:9:26: error: 's' was not declared in this scope
    9 | #define s.length() (int)(s.length())
      |                          ^
password.cpp:19:25: note: in expansion of macro 's'
   19 |     for (int i = 0; i < s; i++)
      |                         ^
password.cpp:27:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for (int j = 1; j <= ans.length(); j++)
      |                         ~~^~~~~~~~~~~~~~~
password.cpp:43:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |             if (ans.length() == n) break;
      |                 ~~~~~~~~~~~~~^~~~
password.cpp:45:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |         if (ans.length() == n) break;
      |             ~~~~~~~~~~~~~^~~~