Submission #867364

# Submission time Handle Problem Language Result Execution time Memory
867364 2023-10-28T09:31:07 Z Ning07 Aliens (IOI07_aliens) C++17
0 / 100
3 ms 596 KB
#pragma warning(disable : 4996)
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
#define L(i,j,k) for(int i=(j);i<=(k);i++)
#define R(i,j,k) for(int i=(j);i>=(k);i--)

int n, x_given, y_given, sz;
int ansx, ansy;
void read() {
    cin >> n >> x_given >> y_given;
    return;
}
bool ask(int x, int y) {
    cout << "examine " << x << ' ' << y << endl;
    fflush(stdout);
    string s; cin >> s;
    return s == "true";
}
bool is_grass(int x, int y) {
    if (x <= 0 || x >= n + 1 || y <= 0 || y >= n + 1) return false;
    return ask(x, y);
}
pair<int, int> last_black(int x, int y, int dx, int dy) {
    int t = 0, meow=-1;
    while (is_grass(x + dx * (1 << t), y + dy * (1 << t))) {
        meow = 1;  t++;
    }
    if (meow==-1) return make_pair(x, y);
    return last_black(x + dx * (1 << t), y + dy * (1 << t), dx, dy);
}
int count_block(int x, int y, int dx, int dy) {
    int t = 1;
    while (is_grass(x + dx * sz * t, y + dy * sz * t)) t++;
    return max(0, t - 1);
}
void is_centre(int x, int y) {
    if (x <= 0 || x >= n + 1 || y <= 0 || y >= n + 1) return;
    bool ok = true;
    ok &= count_block(x, y, 1, 0) == 1;
    ok &= count_block(x, y, -1, 0) == 1;
    ok &= count_block(x, y, 0, 1) == 1;
    ok &= count_block(x, y, 0, -1) == 1;
    if (ok) {
        ansx = x; 
        ansy = y;
        //cout << "Yes this is the centre\n";
    }
}
void find_centre() {
    pair<int, int> a = last_black(x_given, y_given, 0, 1);
    pair<int, int> b = last_black(x_given, y_given, 0, -1);
    pair<int, int> c = last_black(x_given, y_given, 1, 0);
    pair<int, int> d = last_black(x_given, y_given, -1, 0);
   // cout << a.first << ' ' << a.second << '\n';
   // cout << b.first << ' ' << b.second << '\n';
    //cout << c.first << ' ' << c.second << '\n';
    //cout << d.first << ' ' << d.second << '\n';
    int difx = max({ a.first,b.first,c.first,d.first }) - min({ a.first,b.first,c.first,d.first });
    int dify = max({ a.second,b.second,c.second,d.second }) - min({ a.second,b.second,c.second,d.second });
    sz = difx + 1; 
    //cout << "size , sx , sy: ";
    int midx = min({ a.first,b.first,c.first,d.first }) + difx / 2;
    int midy = min({ a.second,b.second,c.second,d.second }) + dify / 2;
    //cout << sz << ' ' << midx << ' ' << midy << '\n';
    for (int i = -4; i <= 4; i++) {
        for (int j = -4; j <= 4; j++) {      
            //cout << "checking if " << midx + i * sz << ' ' << midy + j * sz << " is a centre";
            //cout << '\n';
            is_centre(midx + i * sz, midy + j * sz);
        }
    }
    cout << "solution " << ansx << ' ' << ansy << '\n';
    fflush(stdout);

}
int main() {
    read();
    /*R(i, n, 1) L(j, 1, n) {
        char p; cin >> p;
        if (p == '1') can[j][i] = 1;
        else can[j][i] = 0;
    }
    cout << can[5][3] << '\n';  */
    find_centre();
}

Compilation message

aliens.cpp:1: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    1 | #pragma warning(disable : 4996)
      |
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Runtime error 3 ms 436 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 436 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 436 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -