이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fun.h"
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pair<int,int>>
#define vll vector<pair<long long,long long>>
#define pb push_back
#define ll long long
#define ld long double
#define nl '\n'
#define boost ios::sync_with_stdio(false)
#define mp make_pair
#define se second
#define fi first
#define fore(i, y) for(int i = 0; i < y; i++)
#define forr(i,x,y) for(int i = x;i<=y;i++)
#define forn(i,y,x) for(int i = y; i >= x; i--)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define clr(v,k) memset(v,k,sizeof(v))
#define rall(v) v.rbegin() , v.rend()
#define pii pair<int,int>
#define pll pair<ll , ll>
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 1;
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD)
ll lcm(ll a , ll b) {return a * (b / gcd(a , b));} // least common multiple (PPCM)
// HERE IS THE SOLUTION
vi createFunTour(int n , int q)
{
map<pair<int,int> , int> dist;
int diam = 0;
fore(i , n)
{
forr(j, i + 1 , n - 1)
{
dist[{i , j}] = hoursRequired(i , j);
diam = max(diam , dist[{i , j}]);
}
}
int a;
fore(i , n)
{
forr(j , i + 1 , n - 1)
{
if(dist[{i , j}] == diam)
{
a = i;
break;
}
}
}
vi ans;
set<int> s;
while(sz(ans) < n)
{
ans.pb(a);
s.insert(a);
int ndiam = 0;
fore(i , n)
{
if(s.count(i))continue;
ndiam = max(ndiam , dist[{min(a,i) , max(a,i)}]);
}
fore(i , n)
{
if(ndiam == dist[{min(a,i) , max(a,i)}])
{
a = i;
break;
}
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:61:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
61 | while(sz(ans) < n)
| ^
# | 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... |