답안 #966407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
966407 2024-04-19T20:10:10 Z anton The Potion of Great Power (CEOI20_potion) C++17
14 / 100
339 ms 18856 KB
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pii pair<int, int>
typedef complex<int> point;

const int INF = 1e9;

int dist(vector<int>& a,  vector<int>& b){
    if(a.size() == 0 || b.size() == 0){
        return INF;
    }   
    int ia =0, ib = 0;

    int res= abs(a[0]-b[0]);
    while(ia<a.size()-1 || ib<b.size()-1){
        if(ia==a.size()-1){
            ib++;
        }
        else if(ib==b.size()-1){
            ia++;
        }
        else if(a[ia]<=b[ib]){
            ia++;
        }
        else{
            ib++;
        }

        res = min(res, abs(a[ia]-b[ib]));
    }
    return res;
}

vector<vector<int>> vs;
vector<int> h;
set<pii> cur;
int n;

void init(int N, int D, int H[]) {
    vs.resize(N);
    h.resize(N);
    for(int i = 0; i<N; i++){
        h[i] = H[i];
    }
    n= N;
}

int u;

void curseChanges(int U, int A[], int B[]) {
    u = U;
    for(int i = 0; i<U; i++){
        int a= A[i], b= B[i];
        if(cur.find({a, b})!=cur.end()){
            cur.erase({a, b});
        }
        else if(cur.find({b, a})!=cur.end()){
            cur.erase({b, a});
        }
        else{
            cur.insert({a, b});
        }
    }

    for(auto e: cur){
        vs[e.first].push_back(h[e.second]);
        vs[e.second].push_back(h[e.first]);
    }

    for(int i = 0; i<n; i++){
        sort(vs[i].begin(), vs[i].end());
    }
}

int question(int x, int y, int v) {
    return dist(vs[x],vs[y]);
}

Compilation message

potion.cpp: In function 'int dist(std::vector<int>&, std::vector<int>&)':
potion.cpp:17:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     while(ia<a.size()-1 || ib<b.size()-1){
      |           ~~^~~~~~~~~~~
potion.cpp:17:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     while(ia<a.size()-1 || ib<b.size()-1){
      |                            ~~^~~~~~~~~~~
potion.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if(ia==a.size()-1){
      |            ~~^~~~~~~~~~~~
potion.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         else if(ib==b.size()-1){
      |                 ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 568 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 222 ms 18856 KB Output is correct
2 Correct 250 ms 18592 KB Output is correct
3 Correct 95 ms 5656 KB Output is correct
4 Correct 248 ms 7836 KB Output is correct
5 Correct 208 ms 14688 KB Output is correct
6 Correct 339 ms 10024 KB Output is correct
7 Correct 179 ms 10292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 182 ms 18676 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1980 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -