QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#690022#1139. StationssnpmrnhlolCompile Error//C++171.5kb2024-10-30 19:50:542024-10-30 19:50:55

Judging History

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

  • [2024-10-30 19:50:55]
  • 评测
  • [2024-10-30 19:50:54]
  • 提交

stations

#include "stations.h"
#include <vector>
#include <iostream>
using namespace std;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    vector <vector<int>> e;
    vector<int> labels;
    e.resize(n);
    int cnt = 0;
    auto dfs = [&](auto self, int node, int p, int d) -> void{
        if(d == 0)labels[node] = cnt++;
        for(auto i:e[node]){
            if(i == p)continue;
            self(self, i, node, d^1);
        }
        if(d == 1)labels[node] = cnt++;
    };
	labels.resize(n);
	for(int i = 0;i < n - 1;i++){
        e[u[i]].push_back(v[i]);
        e[v[i]].push_back(u[i]);
	}
	for(int i = 0;i < n;i++){
        if(e[i].size() == 1){
            dfs(dfs, i, -1, 0);
            break;
        }
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    if(c.size() == 1)return c[0];
    sort(c.begin(),c.end());
    if(s < c[0]){
        if(s <= t && t <= c[(int)c.size() - 2]){
            int nr = 1000000;
            for(auto i:c){
                if(t <= i){
                    nr = min(nr, i);
                }
            }
            return nr;
        }else{
            return c[(int)c.size() - 1];
        }
    }else{
        if(c[1] <= t && t <= s){
            int nr = -1;
            for(auto i:c){
                if(i <= t){
                    nr = max(nr, i);
                }
            }
            return nr;
        }else{
            return c[0];
        }
    }
}

詳細信息

stations.code: In function ‘int find_next_station(int, int, std::vector<int>)’:
stations.code:34:5: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   34 |     sort(c.begin(),c.end());
      |     ^~~~
      |     short
grader_stations.cpp: In function ‘int main(int, char**)’:
grader_stations.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d", &phaseid);
      |         ~~~~~^~~~~~~~~~~~~~~~