답안 #641735

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
641735 2022-09-17T13:56:20 Z Vladth11 The Potion of Great Power (CEOI20_potion) C++14
17 / 100
3000 ms 11268 KB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
 
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
 
const int NMAX = 100001;
const int VMAX = 101;
const int INF = 2e9;
const int MOD = 1000000007;
const int BLOCK = 447;
const int base = 117;
const int nr_of_bits = 24;
const int inv2 = 500000004;
 
vector <pii> events[NMAX];
int a[NMAX];
 
void init(int N, int D, int H[]) {
    for(int i = 0; i < N; i++){
        a[i] = H[i];
    }
}
 
void curseChanges(int U, int A[], int B[]) {
    for(int i = 0; i < U; i++){
        events[A[i]].push_back({B[i], i});
        events[B[i]].push_back({A[i], i});
    }
}
 
int question(int x, int y, int v) {
    set <int> stX, stY;
    for(auto p : events[x]){
        if(p.second + 1 > v) break;
        if(stX.find(p.first) == stX.end())
            stX.insert(p.first);
        else stX.erase(p.first);
    }
    for(auto p : events[y]){
        if(p.second + 1 > v) break;
        if(stY.find(p.first) == stY.end())
            stY.insert(p.first);
        else stY.erase(p.first);
    }
    int last, ultim = -1;
    int minim = 1e9;
    if(stX.size() == 0 || stY.size() == 0)
        return minim;
    set <int> nou;
    for(auto p : stX){
        nou.insert(a[p]);
    }
    for(auto p : stY){
        int val = a[p];
        auto it = nou.lower_bound(val);
        if(it != nou.end()){
            minim = min(minim, abs((*it) - val));
        }
        it = nou.upper_bound(val);
        if(it != nou.begin()){
            it = prev(it);
            minim = min(minim, abs((*it) - val));
        }
    }
    return minim;
}
 

Compilation message

potion.cpp: In function 'int question(int, int, int)':
potion.cpp:48:9: warning: unused variable 'last' [-Wunused-variable]
   48 |     int last, ultim = -1;
      |         ^~~~
potion.cpp:48:15: warning: unused variable 'ultim' [-Wunused-variable]
   48 |     int last, ultim = -1;
      |               ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2640 KB Output is correct
2 Correct 3 ms 2640 KB Output is correct
3 Correct 3 ms 2640 KB Output is correct
4 Correct 15 ms 3460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 201 ms 11208 KB Output is correct
2 Correct 165 ms 11232 KB Output is correct
3 Execution timed out 3082 ms 8692 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 120 ms 11268 KB Output is correct
2 Execution timed out 3056 ms 9336 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3152 KB Output is correct
2 Correct 301 ms 2948 KB Output is correct
3 Correct 2803 ms 2936 KB Output is correct
4 Execution timed out 3078 ms 3272 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 3 ms 2640 KB Output is correct
3 Correct 3 ms 2640 KB Output is correct
4 Correct 3 ms 2640 KB Output is correct
5 Correct 15 ms 3460 KB Output is correct
6 Correct 201 ms 11208 KB Output is correct
7 Correct 165 ms 11232 KB Output is correct
8 Execution timed out 3082 ms 8692 KB Time limit exceeded
9 Halted 0 ms 0 KB -