QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#461302#8812. Library 3thangthangCompile Error//C++20772b2024-07-02 17:35:502024-07-02 17:35:52

Judging History

你现在查看的是最新测评结果

  • [2024-07-02 17:35:52]
  • 评测
  • [2024-07-02 17:35:50]
  • 提交

answer

#include <bits/stdc++.h>
#include "library3.h"

using namespace std;

void solve(int N){
    vector <int> ans;
    for (int i = 0; i < N; ++ i) ans.push_back(i);

    int last = query(ans);
    for (int i = 1; i < N; ++ i){
        int cur = i;
        int l = 0;
        int r = i - 1;
        while (l <= r){
            int mid = l + r >> 1;
            vector <int> ask = ans;
            ask[0] = ans[i];
            for (int i = 1; i <= mid; ++ i) ask[i] = ans[i - 1];
            ask[i] = ans[0];
            if (query(ask) > last + mid){
                cur = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
        swap(ans[i], ans[cur]);
        last = query(ans);
    }

    return ans;
}

详细

implementer.cpp: In function ‘int query(std::vector<int>)’:
implementer.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d",&ret);
      |         ~~~~~^~~~~~~~~~~
implementer.cpp: In function ‘int main()’:
implementer.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
answer.code: In function ‘void solve(int)’:
answer.code:31:12: error: return-statement with a value, in function returning ‘void’ [-fpermissive]
   31 |     return ans;
      |            ^~~