답안 #1053867

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053867 2024-08-11T19:10:58 Z VMaksimoski008 케이크 (CEOI14_cake) C++17
0 / 100
2000 ms 4756 KB
#include <bits/stdc++.h>
//#define int long long

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 3e5 + 5;

struct SegTree {

};

signed main() {
    ios_base::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);

    int n, s, q;
    cin >> n >> s;

    vector<ll> v(n+1), v2;
    for(int i=1; i<=n; i++) cin >> v[i], v[i] *= (ll)1e6;
    for(int i=1; i<=n; i++) v2.push_back(i);
    sort(v2.begin(), v2.end(), [&](int a, int b) {
        return v[a] > v[b];
    });

    while(v2.size() > 10) v2.pop_back();

    cin >> q;
    while(q--) {
        char t;
        cin >> t;

        if(t == 'F') {
            int p;
            cin >> p;

            if(p == s) {
                cout << 0 << '\n';
                continue;
            }

            int l=s, r=s, ans=0;
            while(l != p && r != p) {
                ans++;
                if(l - 1 == 0) r++;
                else if(r + 1 > n) l--;
                else if(v[l-1] < v[r+1]) l--;
                else r++;
            }

            cout << ans << '\n';
        } else {
            int a, b;
            cin >> a >> b;
            v[a] = v[v2[b-1]] + 1;
            
            //check if its almost in top 10
            bool ok = 0;
            for(int i=0; i<v2.size()&&!ok; i++)
                if(v2[i] == a) ok = 1;
            
            if(!ok) v2.push_back(a);

            sort(v2.begin(), v2.end(), [&](int a, int b) {
                return v[a] > v[b];
            });

            if(!ok) v2.pop_back();
        }
    }

    return 0;
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:65:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |             for(int i=0; i<v2.size()&&!ok; i++)
      |                          ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 68 ms 604 KB Output isn't correct
2 Incorrect 47 ms 600 KB Output isn't correct
3 Incorrect 53 ms 604 KB Output isn't correct
4 Correct 50 ms 600 KB Output is correct
5 Incorrect 64 ms 860 KB Output isn't correct
6 Incorrect 58 ms 988 KB Output isn't correct
7 Incorrect 67 ms 988 KB Output isn't correct
8 Correct 59 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2029 ms 2264 KB Time limit exceeded
2 Execution timed out 2047 ms 2264 KB Time limit exceeded
3 Execution timed out 2040 ms 2264 KB Time limit exceeded
4 Incorrect 0 ms 344 KB Output isn't correct
5 Execution timed out 2027 ms 4568 KB Time limit exceeded
6 Execution timed out 2028 ms 4564 KB Time limit exceeded
7 Execution timed out 2074 ms 4756 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 596 KB Output isn't correct
2 Incorrect 168 ms 608 KB Output isn't correct
3 Execution timed out 2032 ms 1500 KB Time limit exceeded
4 Execution timed out 2066 ms 1504 KB Time limit exceeded
5 Incorrect 200 ms 792 KB Output isn't correct
6 Execution timed out 2019 ms 2008 KB Time limit exceeded
7 Incorrect 1164 ms 1104 KB Output isn't correct
8 Incorrect 277 ms 2264 KB Output isn't correct
9 Execution timed out 2072 ms 4568 KB Time limit exceeded
10 Incorrect 677 ms 1356 KB Output isn't correct
11 Execution timed out 2073 ms 1164 KB Time limit exceeded
12 Execution timed out 2045 ms 4052 KB Time limit exceeded
13 Execution timed out 2044 ms 4564 KB Time limit exceeded