QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106824#5206. Hot and ColdjoesmittyWA 4ms3436kbC++145.4kb2023-05-19 14:03:442023-05-19 14:03:47

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-19 14:03:47]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3436kb
  • [2023-05-19 14:03:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef vector<int> vi;
typedef vector< vector <int> > vvi;
typedef pair<int, int> pii;
typedef pair < pair < int, int >, int > piii;
typedef pair < pair <int, int > , pair <int, int> > piiii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
 
#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define RFOR(i,a,b) for(int i = a-1; i >= b; i --)
#define all(a) a.begin(), a.end()
//#define endl '\n';
#define sz(x) (int)(x).size()
 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
 
template <typename T>
void pr(vector<T> &v) {
    FOR(i, 0, sz(v)) cout << v[i] << " ";
    cout << endl;
}
template <typename T>
void pr(vector<vector<T> > &v) {
    FOR(i, 0, sz(v)) { pr(v[i]); }
}
template <typename T>
void re(T &x) {
    cin >> x;
}
template <typename T>
void re(vector<T> &a) {
    FOR(i, 0, sz(a)) re(a[i]);
}
template <class Arg, class... Args>
void re(Arg &first, Args &... rest) {
    re(first);
    re(rest...);
}
template <typename T>
void pr(T x) {
    cout << x << endl;
}
template <class Arg, class... Args>
void pr(const Arg &first, const Args &... rest) {
    cout << first << " ";
    pr(rest...);
    cout << endl;
}
void ps() { cout << endl; }
template<class T, class... Ts>
void ps(const T& t, const Ts&... ts) {
    cout << t; if (sizeof...(ts)) cout << " "; ps(ts...);
}
 
const ll MOD  =  998244353;
#define inf 1e18;
#define INF INT_MAX;
 
long double PI = 4*atan(1);
long double eps = 1e-12;

string close = "", far = "";

// ll P_X = -1;
// ll P_Y = -1;

// ll ANS_X = 54;
// ll ANS_Y = 32;

int cntr = 4;

// string spit(ll x, ll y) {
//     ll T_X = P_X, T_Y = P_Y;
//     P_X = x; P_Y = y;
    
//     if(T_X < 0) {
//         return "garbo";
//     }

//     ll d_pre = (ANS_X - T_X) * (ANS_X - T_X) + (ANS_Y - T_Y) * (ANS_Y - T_Y);
//     ll d_cur = (ANS_X - x) * (ANS_X - x) + (ANS_Y - y) * (ANS_Y - y);

//     if(d_cur == 0) {
//         cout << "correct guess " << x << " " << y << endl;
//         return "YES!";
//     }
//     if(d_pre < d_cur) return "FARTHER";
//     if(d_pre > d_cur) return "CLOSER";
//     return "SAME DIST";
// }

int process(int x, int y) {
    cntr++;
    // cout << "C: " << cntr << endl;
    string res; 
    cout << x << " " << y << endl;
    getline(cin, res);
    // res = spit(x,y);
   
    int n = res.length();

    if(res[n-1] == '!') {
        return 100;
    }
    if(res == close) return 1;
    if(res == far) return -1;
    return 0;
}

int main() {
    //auto start = chrono::high_resolution_clock::now();
   // ios_base::sync_with_stdio(0);cin.tie(0);
    // freopen("promote.in", "r", stdin);
	// freopen("promote.out", "w", stdout);
    #ifdef DEBUG
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif 

    // cin >> ANS_X >> ANS_Y;

    string res;
    cout << 0 << " " << 0 << endl;
   getline(cin, res);
    // res = spit(0,0);
    if(res[res.size() - 1] == '!') return 0;
    
    
    cout << 1 << " " << 1 << endl;
    getline(cin, res);
    // res = spit(1,1);
    if(res[res.size() - 1] == '!') return 0;
    close = res;
    

    cout << 0 << " " << 1 << endl;
    getline(cin, res);
    // res = spit(0,1);
    if(res[res.size() - 1] == '!') return 0;
    if(res != close) {
        far = res;
    }
    
    cout << 1 << " " << 0 << endl;
    getline(cin, res);
    // res = spit(1,0);

    if(res[res.size() - 1] == '!') return 0;
    if(res != close && far == "") {
        far = res;
    }

    // cout << close << " | " << far << endl;

    int lo_x = 0;
    int hi_x = 1000000;
    int lo_y = 0;
    int hi_y = 1000000;

    
    while(lo_x < hi_x || lo_y < hi_y) {
       // cout << lo_x << " " << hi_x << " | " << lo_y << " " << hi_y << endl;
        int mid_x = (lo_x + hi_x)/2;
        int mid_y = (lo_y + hi_y)/2;

        int nlo_x = lo_x;
        int nlo_y = lo_y;
        int nhi_x = hi_x;
        int nhi_y = hi_y;

        int ans1 = process(lo_x, lo_y);
        if(ans1 == 100) return 0;

        if(lo_x < hi_x) {
            int ans2 = process(hi_x, lo_y);
            if(ans2 == 100) return 0;

            if(ans2 == 1) {
                nlo_x = mid_x + 1;
            }
            if(ans2 == -1) {
                nhi_x = mid_x - (hi_x - lo_x) % 2;
            }
            if(ans2 == 0) {
                nlo_x = mid_x;
                nhi_x = mid_x;
            }
        }

        

        if(lo_y < hi_y) {
            int ans3 = process(hi_x, hi_y);
            if(ans3 == 100) return 0;
            if(ans3 == 1) {
                nlo_y = mid_y + 1;
            } else if(ans3 == -1) {
                nhi_y = mid_y - (hi_y - lo_y) % 2;
            } else {
                nlo_y = mid_y;
                nhi_y = mid_y;
            }
        }
        lo_x = nlo_x;
        lo_y = nlo_y;
        hi_x = nhi_x;
        hi_y = nhi_y;
    }

    
    int ans1 = process(lo_x, lo_y);


    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::microseconds>(stop - start);
    // cout << duration.count() << endl;
    //cin.close();
    //cout.close();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 3436kb

input:

Tabilmadi
Daha yakin
Dalej
Daha yakin
Dalej
Dalej
Dalej
Daha yakin
Dalej
Dalej
Daha yakin
Dalej
Dalej
Daha yakin
Dalej
Dalej
Daha yakin
Dalej
Dalej
Daha yakin
Dalej
Dalej
Daha yakin
Dalej
Dalej
Daha yakin
Dalej
Dalej
Daha yakin
Dalej
Dalej
Daha yakin
Dalej
Dalej
Daha yakin
Daha yakin
Dalej
Daha yaki...

output:

0 0
1 1
0 1
1 0
0 0
1000000 0
1000000 1000000
0 0
500000 0
500000 500000
0 0
250000 0
250000 250000
0 0
125000 0
125000 125000
0 0
62500 0
62500 62500
0 0
31250 0
31250 31250
0 0
15625 0
15625 15625
0 0
7811 0
7811 7811
0 0
3904 0
3904 3904
0 0
1952 0
1952 1952
0 0
976 0
976 976
489 0
976 0
976 488
...

result:

wrong answer Used 64 points but did not win