답안 #846186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
846186 2023-09-07T12:13:23 Z vjudge1 OGLEDALA (COI15_ogledala) C++
19 / 100
54 ms 10080 KB
#include <bits/stdc++.h>
using namespace std;
#pragma optimize "DostSeferoğlu"
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx2,tune=native")
#define int long long
#define pii pair<int,int>
#define bg begin
#define vi vector<int>
#define endl '\n'
#define vvi vector<vi> 
#define vp vector<pii>
#define sp << " " << 
#define ff first
#define ss second
#define brake {cout << "OK\n";return;}
#define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;}
#define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx)
#define F(xx,yy) for (int xx=1;xx<=yy;++xx)
#define pb push_back 
const int inf = 1e18;
const int MOD = 998244353;   
const int N = 3e5+1;

class Compare {
    public:
       bool operator()(pair<int,pii> a, pair<int,pii> b){
           if(a.ff == b.ff)return a.ss.ff > b.ss.ff;
           return a.ff < b.ff;
        }
}; 

void solve() {
    int n,m,q;
    cin >> n >> m >> q;
    if (n <= 300000) {
        priority_queue<pair<int,pii>,vector<pair<int,pii>>,Compare> pq;
        vi full(n+1,0);
        vi ans(n+1,0);
        int c = 1;
        for (int i=1;i<=m;i++) {
            cin >> ans[i];
            full[ans[i]] =1;
        }
        for (int i=1;i<=n;) {
            if (full[i]) {
                i++;
                continue;
            }
            int j = i;
            while (j<=n && !full[j]) j++;
            j--;
            pq.push({j-i+1,{i,j}});
            i=j+1;
        }
        for (int i=m+1;i<=n;i++) {
            auto f = pq.top();
            pq.pop();
            int l = f.ss.first;
            int r = f.ss.ss;
            int mid = (l+r)/2;
            if (l<=mid-1) pq.push({mid-l,{l,mid-1}});
            if(mid+1<=r) pq.push({r-mid,{mid+1,r}});
            ans[i] = mid;
        }
        while (q--) {
            int ind;
            cin >> ind;
            cout << ans[ind] << endl;   
        }
    }
}                 






signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);
    #ifdef Local
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);  
    #endif
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}

Compilation message

ogledala.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize "DostSeferoğlu"
      | 
ogledala.cpp: In function 'void solve()':
ogledala.cpp:40:13: warning: unused variable 'c' [-Wunused-variable]
   40 |         int c = 1;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 23 ms 3792 KB Output is correct
4 Correct 28 ms 4036 KB Output is correct
5 Correct 50 ms 9664 KB Output is correct
6 Correct 54 ms 10080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -