Submission #755766

# Submission time Handle Problem Language Result Execution time Memory
755766 2023-06-10T15:58:20 Z vjudge1 Password (RMI18_password) C++17
0 / 100
9 ms 208 KB
#include<bits/stdc++.h>
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pbds tree<pair<int, int>, null_type, less<pair<int, int>>,rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
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)
int dx[8] = {1, 0, 0, -1, 1, 1, -1, -1};
int dy[8] = {0, 1, -1, 0, 1, -1, -1, 1};
#define endl "\n"
#define ss second
#define ff first
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define vi vector<int>
#define vii vector<pair<int,int>>
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd  pair<double,double>
#define vdd  vector<pdd>
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
////////////////////Only Clear Code//////////////////////////

void init(){
    #ifndef ONLINE_JUDGE
 
freopen("input.txt", "r", stdin);
 
freopen("output.txt", "w", stdout);
 
#endif // ONLINE_JUDGE
}

const int mx = 1e6+9;
const int LOG = 25;
const ll inf = 1e18;
const ll mod = 1e9+7;

int freq[30];

int query(string str);

string guess(int n, int s){
    for(int i = 0; i < s;i++){
        char x = i+'a';
        string c = string(1, x);
        for(int j = 0; j < n;j++){
            int res = query(c);
            if(res == c.size())freq[i]++;
            else break;
            c += x;
        }
    }
    string c = "";
    for(int i = 0; i < s;i++){
        char x = i+'a';
        if(freq[i] != 0){
            int k = freq[i];
            while(k--){
                c += x;
            }
            freq[i] = 0;
            break;
        }
    }
    /*
    for(int i = 0; i < s;i++){
        if(freq[i] == 0)continue;
        char x = i+'a';
        int last = 0;
        int k = freq[i];
        while(k--){
            int l = last, r = c.size();
            int ind = 0;
            while(l < r){
                int md = (l+r)/2;
                string temp = c;
                temp.insert(md, string(1, x));
                int b = query(temp);
                if(b >= md+1){
                    ind = md;
                    l = md;
                }
                else{
                    r = md-1;
                }
            }
            c.insert(ind, string(1, x));
        }
        //freq[i] = 0;
    }
    //cout << c << endl;*/
    return c;
}
/*
void run_case(){
    cout << guess(4, 4) << endl;
}

int main(){
    init();
    speed;
    int t;
    //cin >> t;
    t = 1;
    while(t--){
        run_case();
    }
}*/

/*
    NEVER GIVE UP!
    DOING SMTHNG IS BETTER THAN DOING NTHNG!!!
    Your Guide when stuck:
    - Continue keyword only after reading the whole input
    - Don't use memset with testcases
    - Check for corner cases(n=1, n=0)
    - Check where you declare n(Be careful of declaring it globally and in main)
*/  

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:57:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             if(res == c.size())freq[i]++;
      |                ~~~~^~~~~~~~~~~
password.cpp: In function 'void init()':
password.cpp:35:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
password.cpp:37:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 31 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 53 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 208 KB Returned early from guess() after 1013 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 31 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 31 queries.
2 Halted 0 ms 0 KB -