답안 #681590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681590 2023-01-13T12:17:16 Z drdilyor Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
8 / 100
3000 ms 6280 KB
#include <bits/stdc++.h>
#ifdef ONPC
    #include "t_debug.cpp"
#else
    #define debug(...) 42
#endif
using namespace std;
//namespace pbds = __gnu_pbds;
using ll = long long;
const int inf = 1e9;
const ll infl = 1e18;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; }
template<typename Cont> int sz(const Cont& cont) { return int(cont.size()); }
const string fileio = "";
constexpr int tests = 0, nmax = 2e5, nlog = __lg(nmax), mod = 1e9+7;

int solve() {
    int n, m;
    cin >> n >> m;
    if (!cin) return 1;

    vector<int> arr(n);
    for (int& i: arr) cin >> i;
    while (m--) {
        int l, r, k;
        cin >> l >> r >> k;
        vector<int> brr(arr.begin()+l-1, arr.begin() + r);
        debug(brr);
        for (int i = sz(brr)-1; i >= 1; i--) {
            for (int j = 0; j < i; j++) {
                if (brr[j] + brr[j+1] <= k && brr[j] > brr[j+1])
                    swap(brr[j], brr[j+1]);
            }
        }
        debug(brr);
        cout << is_sorted(brr.begin(), brr.end()) << '\n';
    }

    return 0;
}

signed main() {
    int t = 1;
    #ifdef ONPC
    t = 10000;
    #else
    if (fileio.size()) {freopen((fileio+".in").c_str(),"r",stdin);freopen((fileio+".out").c_str(),"w",stdout);}
    #endif
    cin.tie(0)->sync_with_stdio(0);
    if (tests) cin >> t;
    while (t-- && cin) {
        if (solve()) break;
        #ifdef ONPC
            cout << "____________________" << endl;
        #endif
    }
    return 0;
}

/*
     █████               █████  ███  ████                               
    ▒▒███               ▒▒███  ▒▒▒  ▒▒███                               
  ███████  ████████   ███████  ████  ▒███  █████ ████  ██████  ████████ 
 ███▒▒███ ▒▒███▒▒███ ███▒▒███ ▒▒███  ▒███ ▒▒███ ▒███  ███▒▒███▒▒███▒▒███
▒███ ▒███  ▒███ ▒▒▒ ▒███ ▒███  ▒███  ▒███  ▒███ ▒███ ▒███ ▒███ ▒███ ▒▒▒ 
▒███ ▒███  ▒███     ▒███ ▒███  ▒███  ▒███  ▒███ ▒███ ▒███ ▒███ ▒███     
▒▒████████ █████    ▒▒████████ █████ █████ ▒▒███████ ▒▒██████  █████    
 ▒▒▒▒▒▒▒▒ ▒▒▒▒▒      ▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒   ▒▒▒▒▒███  ▒▒▒▒▒▒  ▒▒▒▒▒     
                                            ███ ▒███                    
                                           ▒▒██████                     
                                            ▒▒▒▒▒▒
*/

Compilation message

sortbooks.cpp: In function 'int solve()':
sortbooks.cpp:5:24: warning: statement has no effect [-Wunused-value]
    5 |     #define debug(...) 42
      |                        ^~
sortbooks.cpp:30:9: note: in expansion of macro 'debug'
   30 |         debug(brr);
      |         ^~~~~
sortbooks.cpp:5:24: warning: statement has no effect [-Wunused-value]
    5 |     #define debug(...) 42
      |                        ^~
sortbooks.cpp:37:9: note: in expansion of macro 'debug'
   37 |         debug(brr);
      |         ^~~~~
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:49:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |     if (fileio.size()) {freopen((fileio+".in").c_str(),"r",stdin);freopen((fileio+".out").c_str(),"w",stdout);}
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:49:74: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |     if (fileio.size()) {freopen((fileio+".in").c_str(),"r",stdin);freopen((fileio+".out").c_str(),"w",stdout);}
      |                                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 29 ms 372 KB Output is correct
7 Correct 30 ms 340 KB Output is correct
8 Correct 32 ms 340 KB Output is correct
9 Correct 16 ms 328 KB Output is correct
10 Correct 37 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 29 ms 372 KB Output is correct
7 Correct 30 ms 340 KB Output is correct
8 Correct 32 ms 340 KB Output is correct
9 Correct 16 ms 328 KB Output is correct
10 Correct 37 ms 340 KB Output is correct
11 Correct 1368 ms 540 KB Output is correct
12 Execution timed out 3069 ms 460 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3086 ms 6280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3086 ms 852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 29 ms 372 KB Output is correct
7 Correct 30 ms 340 KB Output is correct
8 Correct 32 ms 340 KB Output is correct
9 Correct 16 ms 328 KB Output is correct
10 Correct 37 ms 340 KB Output is correct
11 Correct 1368 ms 540 KB Output is correct
12 Execution timed out 3069 ms 460 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 29 ms 372 KB Output is correct
7 Correct 30 ms 340 KB Output is correct
8 Correct 32 ms 340 KB Output is correct
9 Correct 16 ms 328 KB Output is correct
10 Correct 37 ms 340 KB Output is correct
11 Correct 1368 ms 540 KB Output is correct
12 Execution timed out 3069 ms 460 KB Time limit exceeded
13 Halted 0 ms 0 KB -