# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
707121 | Alihan_8 | 곤돌라 (IOI14_gondola) | C++17 | 19 ms | 3024 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "gondola.h"
// include <ext/pb_ds/assoc_container.hpp>
// include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
// define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define mpr make_pair
#define ln '\n'
void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
//#define int long long
int valid(int n, int inputSeq[]){
vector <pair<int,int>> res;
for ( int i = 0; i < n; i++ ){
if ( inputSeq[i] <= n ) res.pb({inputSeq[i], i});
}
sort(all(res));
for ( int i = 1; i < (int)res.size(); i++ ){
auto [x, y] = res[i-1];
auto [l, r] = res[i];
r = (r+n-y)%n;
if ( l-x != r ) return false;
}
return true;
}
int replacement(int n, int gondolaSeq[], int ans[]){
vector <int> p;
for ( int i = 0; i < n; i++ ){
p.pb(gondolaSeq[i]);
}
int it = -1;
for ( int i = 0; i < n; i++ ){
if ( p[i] <= n ) it = i;
}
auto F = [&](int x){ return x%n == 0 ? n : x%n; };
vector <int> res(n);
if ( it == -1 ) iota(all(res), 1);
else{
for ( int j = it; j < n; j++ ) res[j] = F(p[it]+j-it);
for ( int j = 0; j < it; j++ ) res[j] = F(p[it]+n-it+j);
}
vector <pair<int,int>> cur;
for ( int i = 0; i < n; i++ ){
cur.pb({p[i], i});
}
sort(all(cur));
int _i = 0, last = n+1;
for ( auto [val, it]: cur ){
while ( res[it] < val ){
ans[_i++] = res[it];
res[it] = last++;
}
}
return _i;
}
int countReplacement(int n, int inputSeq[]){
}
#if false
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int sub_task, n; cin >> n;
const int N = 2e5+1;
int p[n], res[N] = {0};
for ( int i = 0; i < n; i++ ) cin >> p[i];
int len = replacement(n, p, res);
cout << len << ln;
for ( int i = 0; i < len; i++ ) cout << res[i] << ' ';
cout << '\n';
/*
3
3 1 4
answer: 1, {2}
5
5 1 2 3 4
answer: 0, {}
7
2 3 4 9 6 7 1
answer: 2, {5 8}
*/
}
#endif
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |
# | 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... |