이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Problem: C - Hedgehog Daniyar and Algorithms
// Contest: Virtual Judge - Yosik IOI contest #1
// URL: https://vjudge.net/contest/601761#problem/C
// Memory Limit: 256 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(v) (v).begin(),(v).end()
#define rall(v) ((v).rbegin()), ((v).rend())
#define out(v) for(auto& i : v) cout << i << ' ';
#define F first
#define S second
#define int long long
const ll N = 5000 + 17;
const ll MOD = 1e9 + 7;
const string alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int a[N] , b[N] , pref[N];
void solve (){
int n , m;
cin >> n >> m;
int ok = 1;
for(int i = 1; i <= n; i ++){
cin >> a[i];
}
for(int i = 1; i <= n; i ++){
pref[i] = pref[i - 1];
if (a[i] < a[i - 1]){
pref[i] = i;
}
}
if (n <= 5000 && m <= 5000){
for(int x = 1; x <= m; x ++){
int l ,r , k;
cin >> l >> r >> k;
for(int i = l ; i <= r; i ++){
b[i] = a[i];
}
for (int j = l; j <= r; j++) {
for (int i = l; i < r; i++) {
if (b[i] > b[i + 1] && b[i] + b[i + 1] <= k) {
swap(b[i], b[i + 1]);
}
}
}
int ok = 1;
for(int i= l; i < r; i ++){
if (b[i] > b[i + 1]){
ok = 0;
break;
}
}
cout << ok << endl;
}
}
else {
for(int x = 1; x <= m; x++){
int l , r , k;
cin >> k >> r >> k;
cout << (pref[r] <= l) << endl;
}
}
}
signed main(){
// freopen("ones.in" , "r" , stdin) ;
// freopen("ones.out" , "w" , stdout) ;
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1;
// int cs = 1;
// cin >>T;
while (T --){
// cout <<"Case " << cs ++<< ":" << endl;
solve ();
// cout <<endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
sortbooks.cpp: In function 'void solve()':
sortbooks.cpp:31:6: warning: unused variable 'ok' [-Wunused-variable]
31 | int ok = 1;
| ^~
# | 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... |