Submission #1076105

#TimeUsernameProblemLanguageResultExecution timeMemory
1076105raduvMouse (info1cup19_mouse)C++17
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> #ifndef DEBUG #include "grader.h" #endif using namespace std; vector<int> v, q; void setinterval(int n, int l, int r, int val){ int i; for( i = 1; i <= n; i++ ){ if(i >= l && i <= r) q[i] = val; else q[i] = n + 1; // nu va modifica rezultatul query-ului } } #ifdef DEBUG vector<int> p; int permut[] = {9, 8, 10, 5, 3, 2, 1, 4, 7, 6}; int query(int n){ int i, cnt = 0; for( i = 0; i < n; i++ ){ printf("%d ", q[i]); cnt += (q[i] == p[i]); } printf("\n"); return cnt; } #endif void solve(int n){ //printf("%d ", n); int i, val, st, dr, mij; q.reserve(n + 10); v.reserve(n + 10); for( val = 1; val <= n; val++ ){ // cautam binar pentru fiecare valoare pozitia sa setinterval(n, 1, n, val); st = 1; dr = n + 1; //printf("%d %d", st, dr); while( dr - st > 1 ){ mij = (st + dr) / 2; setinterval(n, st, mij - 1, val); if(query(q)) dr = mij; else st = mij; } v[st] = val; } query(v); return; } #ifdef DEBUG int main(){ int i, n; n = 10; p.reserve(n); for( i = 0; i < n; i++ ){ p[i] = permut[i]; //printf("%d ", p[i]); } solve(n); return 0; } #endif // DEBUG

Compilation message (stderr)

mouse.cpp: In function 'void solve(int)':
mouse.cpp:33:7: warning: unused variable 'i' [-Wunused-variable]
   33 |   int i, val, st, dr, mij;
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...