Submission #1076041

# Submission time Handle Problem Language Result Execution time Memory
1076041 2024-08-26T10:42:11 Z raduv Mouse (info1cup19_mouse) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
void setinterval(int n, int l, int r, int val, vector<int> v){
  int i;
  for( i = 1; i <= n; i++ ){
    if(i >= l && i <= r)
      v[i] = val;
    else
      v[i] = n + 1; // nu va modifica rezultatul query-ului
  }
}
void solve(int n){
  vector <int> q;
  vector <int> v;
  int i, val, st, dr, mij;
  for( val = 1; val <= n; val++ ){
    // cautam binar pentru fiecare valoare pozitia sa
    setinterval(n, 1, n, val, q);
    st = 1;
    dr = n + 1;
    while( dr - st > 1 ){
      mij = (st + dr) / 2;
      setinterval(n, st, mij - 1, val, q);
      if(query(q))
        dr = mij;
      else
        st = mij;
    }
    v[st] = val;
  }
  query(v);
  return;
}

Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:16:7: warning: unused variable 'i' [-Wunused-variable]
   16 |   int i, val, st, dr, mij;
      |       ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -