Submission #342462

# Submission time Handle Problem Language Result Execution time Memory
342462 2021-01-02T07:12:12 Z mario05092929 The Potion of Great Power (CEOI20_potion) C++11
0 / 100
233 ms 27828 KB
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const int TMX = 1 << 18;
const long long llINF = 2e18;
const long long mod = 1e9+7;
const long long hashmod = 100003;
const int MAXN = 100000;
const int MAXM = 1000000;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
typedef vector <pi> vecpi;
typedef long long ll;
set <int> v[100005];
int n,m,d,a[100005];
vecpi edge;


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

void curseChanges(int U, int A[], int B[]) {
    m = U;
    for(int i = 0;i < m;i++) edge.pb({A[i]+1,B[i]+1});
    for(pi i : edge) {
        if(v[i.x].find(i.y) != v[i.x].end()) v[i.x].erase(i.y), v[i.y].erase(i.x);
        else v[i.x].insert(i.y), v[i.y].insert(i.x);
    }
    for(int i = 1;i <= n;i++) {
        cout << i << " : ";
        for(int j : v[i]) cout << j << ' ';
        cout << '\n';
    }
}

bool cmp(int x,int y) {return a[x] < a[y];}

int question(int x,int y,int day) {
    vec l,r;
    x++, y++;
    for(int i : v[x]) l.pb(i);
    for(int i : v[y]) r.pb(i);
    sort(all(l),cmp), sort(all(r),cmp);
    int ans = INF,lp = 0,rp = 0;
    while(lp < l.size()&&rp < r.size()) {
        ans = min(ans,abs(a[l[lp]]-a[r[rp]]));
        if(a[l[lp]] < a[r[rp]]) lp++;
        else rp++;
    }
    return ans;
}

Compilation message

potion.cpp:6: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
    6 | #pragma gcc optimize("O3")
      | 
potion.cpp:7: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
    7 | #pragma gcc optimize("Ofast")
      | 
potion.cpp:8: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
    8 | #pragma gcc optimize("unroll-loops")
      | 
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:59:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     while(lp < l.size()&&rp < r.size()) {
      |           ~~~^~~~~~~~~~
potion.cpp:59:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     while(lp < l.size()&&rp < r.size()) {
      |                          ~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4972 KB Incorrect
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5100 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 233 ms 27748 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 228 ms 27828 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 6252 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4972 KB Incorrect