이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<bool> vb;
typedef set<ll> sll;
#define IOS cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false)
#define INF(dtype) numeric_limits<dtype>::max()
#define NINF(dtype) numeric_limits<dtype>::min()
typedef pair<int, vb> pib;
pib solve(int n, int m, const vi& s, const vi& f) {
vb config(n, false);
if(n == 1) {
// Case 1: n == 1
bool less_exists = false;
bool greater_exists = false;
int spos = s[0];
int ans = 0;
for(int fv : f) {
if(fv < spos) {
less_exists = true;
ans = max(ans, spos - fv);
} else if(fv > spos) {
greater_exists = true;
ans = max(ans, fv - spos);
}
}
config[0] = greater_exists;
if(less_exists && greater_exists) return {-1, config};
return {ans, config};
}
}
int main() {
IOS;
int n, m;
cin >> n >> m;
vi s(n, 0);
vi f(m, 0);
for(int& sv : s) cin >> sv;
for(int& fv : f) cin >> fv;
auto [ans, config] = solve(n, m, s, f);
cout << ans << "\n";
for(const bool& b : config) cout << (b ? 'R' : 'L');
cout << "\n";
cout << flush;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'pib solve(int, int, const vi&, const vi&)':
Main.cpp:21:23: warning: control reaches end of non-void function [-Wreturn-type]
21 | vb config(n, false);
| ^
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |