This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "fun.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> createFunTour(int n, int q) {
vector<int> s(n), d(n), ans;
array<int, 2> c{n+1};
for(int i=0; i<n; ++i) {
s[i]=attractionsBehind(0, i);
if(s[i]>n/2)
c=min(array<int, 2>{s[i], i}, c);
}
vector<int> e;
for(int i=0; i<n; ++i) {
d[i]=hoursRequired(c[1], i);
if(d[i]==1)
e.push_back(i);
}
vector<vector<int>> d2(e.size()-1), f(e.size());
for(int i=0; i<e.size()-1; ++i)
for(int j=0; j<n; ++j)
d2[i].push_back(hoursRequired(e[i], j));
for(int i=0; i<n; ++i) {
if(i==c[1])
continue;
int j=0;
while(j<e.size()-1&&d2[j][i]>d[i])
++j;
f[j].push_back(i);
}
vector<int> g;
for(int i=0; i<e.size(); ++i)
g.insert(g.end(), f[i].begin(), f[i].end());
sort(g.begin(), g.begin()+n/2, [&](const int &i, const int &j) {
return d[i]>d[j];
});
sort(g.begin()+n/2, g.end(), [&](const int &i, const int &j) {
return d[i]>d[j];
});
for(int i=0; i<n/2; ++i) {
ans.push_back(g[i]);
if(i+n/2<g.size())
ans.push_back(g[i+n/2]);
}
ans.push_back(c[1]);
// for(int a : ans)
// cout << a << endl;
return ans;
}
Compilation message (stderr)
fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for(int i=0; i<e.size()-1; ++i)
| ~^~~~~~~~~~~
fun.cpp:27:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | while(j<e.size()-1&&d2[j][i]>d[i])
| ~^~~~~~~~~~~
fun.cpp:32:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i=0; i<e.size(); ++i)
| ~^~~~~~~~~
fun.cpp:42:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | if(i+n/2<g.size())
| ~~~~~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |