이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "rail.h"
using namespace std;
#define ALL(x) x.begin(),x.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define fst first
#define snd second
typedef pair<int,int> ii;
const int C = 1, D = 2;
//int getDistance(int i, int j);
void findLocation(int n, int first, int loc[], int stype[]) {
vector<ii> p(n);
forsn(i,1,n) p[i]={getDistance(0,i),i};
sort(ALL(p));
set<ii> Cs, Ds;
for(auto [d0,i]:p) {
if(Cs.empty()) {
loc[i]=first;
stype[i]=C;
Cs.insert((ii){loc[i],i});
continue;
}
int minC = Cs.begin()->snd;
if(Ds.empty()) {
loc[i]=loc[minC]+d0;
stype[i]=D;
Ds.insert((ii){loc[i],i});
continue;
}
int maxD = Ds.rbegin()->snd;
int distItoC = getDistance(i,minC);
int distItoD = getDistance(maxD,i);
/*loc[i] = loc[minC] + distItoC;
int target = (loc[i] + loc[maxD] - distItoD)/2;
auto it = Cs.lower_bound((ii){target,0});
if(it != Cs.end() && loc[i] - it->fst + loc[maxD] - it->fst == distItoD) {
stype[i] = D;
Ds.insert((ii){loc[i],i});
continue;
}
loc[i] = loc[maxD] - distItoD;
target = (distItoC + loc[i] + loc[minC])/2;
it = Ds.lower_bound((ii){target,0});
if(it != Ds.end() && it->fst - loc[i] + it->fst - loc[minC] == distItoC) {
stype[i] = C;
Cs.insert((ii){loc[i],i});
continue;
}*/
loc[i] = loc[minC] + distItoC;
if(d0 == loc[i] - loc[0]) {
stype[i] = D;
Ds.insert((ii){loc[i],i});
} else {
loc[i] = loc[maxD] - distItoD;
stype[i] = C;
Cs.insert((ii){loc[i],i});
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:20:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
20 | for(auto [d0,i]:p) {
| ^
# | 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... |