답안 #669364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
669364 2022-12-06T10:05:03 Z berr The Potion of Great Power (CEOI20_potion) C++17
0 / 100
444 ms 85592 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+30;
bitset<504> sts[N];
vector<array<int, 2>> adj[N];
map<array<int, 2>, int> mp;
bitset<504> s;
vector<int> h;


void init(int n, int d, int H[]){


    for(int i=0; i<n; i++){
        sts[i]=s;
        h.push_back(H[i]);
    }


}

void curseChanges(int u, int a[], int b[]){
    for(int i=0; i<u; i++){
        adj[a[i]].push_back({h[b[i]], b[i]});
        adj[b[i]].push_back({h[a[i]], a[i]});
    }

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


   for(int i=0; i<N; i++){
        for(int l=0; l<adj[i].size(); l++){
            mp[{i, adj[i][l][1]}]=l;
        }
    }

    for(int i=0; i<u; i++){
        int x=a[i], y=b[i];

        bitset ss=sts[x];
        
        int pos=mp[{x, y}];
        if(ss[pos]==1) ss[pos]=0;
        else ss[pos]=1; 

        sts[x]=ss;


        ss=sts[y];
        pos=mp[{y, x}];

        if(ss[pos]==1) ss[pos]=0;
        else ss[pos]=1; 

        sts[y]=ss;

    }
}


int question(int x, int y, int v){


    bitset sx = sts[x], sy=sts[y];
    int lx=0, ly=0;
      


    int ans=1e9;

    while(lx<sx.size() && ly < sy.size()){
        int vx=adj[x][lx][0];
        int vy=adj[y][ly][0];

        ans=min(ans, abs(vx-vy));

        if(vx < vy){
            lx ++;
            while(lx<sx.size() && sx[lx]==0) lx++;
        }
        else if(vx >= vy){
            ly ++;
            while(ly<sy.size() && sy[ly]==0) ly++;
        }

    }

    return ans;

}

Compilation message

potion.cpp: In function 'void curseChanges(int, int*, int*)':
potion.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int l=0; l<adj[i].size(); l++){
      |                      ~^~~~~~~~~~~~~~
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:73:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::size_t' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     while(lx<sx.size() && ly < sy.size()){
      |           ~~^~~~~~~~~~
potion.cpp:73:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::size_t' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     while(lx<sx.size() && ly < sy.size()){
      |                           ~~~^~~~~~~~~~~
potion.cpp:81:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::size_t' {aka 'long unsigned int'} [-Wsign-compare]
   81 |             while(lx<sx.size() && sx[lx]==0) lx++;
      |                   ~~^~~~~~~~~~
potion.cpp:85:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::size_t' {aka 'long unsigned int'} [-Wsign-compare]
   85 |             while(ly<sy.size() && sy[ly]==0) ly++;
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2640 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2920 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 444 ms 85592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 391 ms 42332 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 5072 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2640 KB Incorrect
2 Halted 0 ms 0 KB -