답안 #414475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
414475 2021-05-30T13:12:02 Z ollel Vision Program (IOI19_vision) C++14
8 / 100
7 ms 716 KB
#include <bits/stdc++.h>
#include <iostream>
#include "vision.h"
using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int h, w, k, inst;

// bool add_or(vi& q) {
//   cout << "or:\n";
//   for(auto &i : q) cout << i << " ";cout<<endl;
//   bool ans; cin >> ans;
//   return ans;
// }
//
// bool add_not(int x ) {
//   cout << "not:\n";
//   cout << x << endl;
//   bool ans; cin >> ans; return ans;
// }

int search()
{
    int low = 0, high = w*h, mid;
    while (high - low > 1) {
      mid = (high + low) / 2;
      vi ask(mid - low);
      rep(i,low,mid) ask[i-low] = i;
      inst++;
      if (add_or(ask)) high = mid;
      else low = mid;
    }
    return low;
}

void findk(int I)
{
  int x = I % w, y = I / w;
  // cout << "coords: " << x << ", "<<y<<endl;

  int first_inst = inst + 1;
  rep(dif, -k, k + 1) {
    int X = x + dif;
    if (X < 0 || X >= w) continue;

    int ydif = k - abs(dif);
    int Y = y + ydif;
    if (Y >= 0 && Y < h) {
      vi ask = {Y * w + X};
      // cout << "coords: " << X << ", "<<Y<<endl;
      add_or(ask);
      inst++;
    }
    Y = y - ydif;
    if (Y >= 0 && Y < h) {
      vi ask = {Y * w + X};
      // cout << "coords: " << X << ", "<<Y<<endl;
      add_or(ask);
      inst++;
    }
  }
  // cout << first_inst << " , "<<inst << endl;
  if (first_inst <= inst){
    vi ask;
    rep(i,first_inst, inst+1) ask.pb(i);
    add_or(ask);
  } else {

      vi ask(1000002);
      rep(i,0,1000002) ask[i];
      add_or(ask);

    add_not(I);
  }
}

void construct_network(int H, int W, int K)
{
  h = H; w = W; k = K;
  inst = w * h - 1;
  int x = search();
  // cout << "X: " << x << endl;
  findk(x);
}

// int main() {
//   int H ,W, K; cin >> H>>W>>K;construct_network(H, W, K);
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 3), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 3 ms 460 KB Output is correct
21 Correct 3 ms 476 KB Output is correct
22 Correct 3 ms 460 KB Output is correct
23 Correct 3 ms 460 KB Output is correct
24 Correct 3 ms 460 KB Output is correct
25 Correct 3 ms 460 KB Output is correct
26 Correct 3 ms 460 KB Output is correct
27 Correct 5 ms 716 KB Output is correct
28 Correct 5 ms 716 KB Output is correct
29 Correct 5 ms 716 KB Output is correct
30 Correct 7 ms 716 KB Output is correct
31 Correct 5 ms 716 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 716 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 0, but computed 1
3 Halted 0 ms 0 KB -