답안 #669598

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
669598 2022-12-06T20:02:14 Z dozer The Potion of Great Power (CEOI20_potion) C++14
0 / 100
252 ms 65236 KB
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define sp " "
#define endl "\n"
#define pii pair<int, int>
#define st first
#define nd second


vector<int> curr[100005];
int arr[100005], n;


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

void curseChanges(int U, int A[], int B[]) {
    map<int, int> done[n + 5];
    for (int i = 0; i < U; i++)
    {
        int x = A[i], y = B[i];
        if (done[x][y])
        {
            done[x][y] = 0;
            done[y][x] = 0;
        }
        else
        {
            done[x][y] = 1;
            done[y][x] = 1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (auto j : done[i])
            if (j.nd == 1) curr[i].pb(arr[j.st]);
        sort(curr[i].begin(), curr[i].end());
    }
   
}

int question(int x, int y, int v) {
    int ans = 1e9;
    int i = 0, j = 0;
    while(i < curr[x].size() && j < curr[j].size())
    {
        int a = curr[x][i], b = curr[y][j];
        ans = min(ans, abs(a - b));
        if (a < b) i++;
        else if (b < a) j++;
        else return ans;
    }
    return ans;
}

Compilation message

potion.cpp: In function 'int question(int, int, int)':
potion.cpp:51:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     while(i < curr[x].size() && j < curr[j].size())
      |           ~~^~~~~~~~~~~~~~~~
potion.cpp:51:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     while(i < curr[x].size() && j < curr[j].size())
      |                                 ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2640 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 5584 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 252 ms 65236 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 211 ms 32220 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 4432 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2640 KB Incorrect
2 Halted 0 ms 0 KB -