답안 #755920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
755920 2023-06-10T17:44:48 Z vjudge1 Password (RMI18_password) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pair<int,int>>
#define vll vector<pair<long long,long long>>
#define pb push_back
#define ll long long
#define ld long double
#define nl '\n'
#define boost ios::sync_with_stdio(false)
#define mp make_pair
#define se second
#define fi first
#define fore(i, y) for(ll i = 0; i < y; i++)
#define forr(i,x,y) for(int i = x;i<=y;i++)
#define forn(i,y,x) for(ll i = y; i >= x; i--)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define clr(v,k) memset(v,k,sizeof(v))
#define rall(v) v.rbegin() , v.rend()
#define pii pair<int,int>
#define pll pair<ll , ll>

const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 1;

ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD)
ll lcm(ll a , ll b) {return a * (b / gcd(a , b));} // least common multiple (PPCM)

// HERE IS THE SOLUTION
vector<vector<string>> possible(5);
void brute(int t)
{
    forr(i , 'a' , 'd')
    {
        string s = "";
        s+=i;
        forr(j , 'a' , 'd')
        {
            s+= j;
            possible[2].pb(s);
            forr(k , 'a' , 'd')
            {
                s+= k;
                possible[3].pb(s);
                forr(l , 'a' , 'd')
                {
                    s+= l;
                    possible[4].pb(s);
                }
            }
        }
    }
}
int query(string s)
{

}

string guess(int n,int s )
{
    string t = "";
    do
    {
        if(sz(t) + s > n)
        {
            if(sz(t) + s - 1 == n)
            {
                for(auto str : possible[s-1])
                {
                    if(query(str + t) == sz(t) + s - 1)
                    {
                        t = str + t;
                        break;
                    }
                }
            }
            else if(sz(t) + s  - 2 == n)
            {
                for(auto str : possible[s-2])
                {
                    if(query(str + t) == sz(t) + s-2)
                    {
                        t = str + t;
                        break;
                    }
                }
            }
        }
        for(auto str : possible[s])
        {
            if(query(str + t) == sz(t) + s)
            {
                t = str + t;
                break;
            }
        }
    }
    while(query(t) != n);
    cout<<t<<nl;
}


Compilation message

password.cpp: In function 'int query(std::string)':
password.cpp:59:1: warning: no return statement in function returning non-void [-Wreturn-type]
   59 | }
      | ^
password.cpp: In function 'std::string guess(int, int)':
password.cpp:66:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |         if(sz(t) + s > n)
      |                      ^
password.cpp:68:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   68 |             if(sz(t) + s - 1 == n)
      |                              ^
password.cpp:72:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |                     if(query(str + t) == sz(t) + s - 1)
      |                        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
password.cpp:79:36: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |             else if(sz(t) + s  - 2 == n)
      |                                    ^
password.cpp:83:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |                     if(query(str + t) == sz(t) + s-2)
      |                        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
password.cpp:93:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |             if(query(str + t) == sz(t) + s)
      |                ~~~~~~~~~~~~~~~^~~~~~~~~~~~
password.cpp:102:1: warning: no return statement in function returning non-void [-Wreturn-type]
  102 | }
      | ^
/usr/bin/ld: /tmp/ccrPSvOt.o: in function `query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x80): multiple definition of `query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/cccS3xnw.o:password.cpp:(.text.unlikely+0x0): first defined here
collect2: error: ld returned 1 exit status