Submission #1015023

# Submission time Handle Problem Language Result Execution time Memory
1015023 2024-07-06T01:31:23 Z hmm789 Mouse (info1cup19_mouse) C++14
0 / 100
1 ms 344 KB
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;

void solve(int n) {
    vector<int> v, ans;
    for(int i = 0; i < n; i++) {
        v.push_back(2);
        ans.push_back(-1);
    }
    for(int i = 0; i < n; i++) {
        v[i] = 1;
        if(query(v) == 2) ans[i] = 1;
        v[i] = 2;
    }
    for(int i = 2; i < n; i++) {
        vector<int> pos;
        for(int j = 0; j < n; j++) {
            if(ans[j] == -1) pos.push_back(j);
            v[j] = ans[j];
        }
        int l = 0, r = pos.size()-1, m;
        while(l < r) {
            m = (l+r)/2;
            for(int j = 0; j <= m; j++) v[pos[j]] = i;
            for(int j = m+1; j < pos.size(); j++) v[pos[j]] = 1;
            if(query(v) == i) r = m;
            else l = m+1;
        }
        ans[pos[l]] = i;
    }
    for(int i = 0; i < n; i++) if(ans[i] == -1) ans[i] = n;
    query(ans);
}

Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:26:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             for(int j = m+1; j < pos.size(); j++) v[pos[j]] = 1;
      |                              ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -