Submission #111899

# Submission time Handle Problem Language Result Execution time Memory
111899 2019-05-16T17:18:31 Z CodeKracker New Home (APIO18_new_home) C++14
0 / 100
5000 ms 19520 KB
/*input
1 1 1
100000000 1 1 1
1 1
*/
/**
    Author: Kristopher Paul
    Date Created: 16-05-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define pb push_back
#define INF 0x3f3f3f3f //0x3f3f3f3f = 63
#define MOD 1000000009
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

ll ModExp(ll x,ll y,ll m){
    ll res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

bool help(pair<pii,pii> a,pair<pii,pii> b){
    if(a.first.first <= b.first.first){
        return true;
    }
    return false;
}

void solve(){
    int n,k,q;
    cin >> n >> k >> q;
    vector<pair<pii,pii> > vec;
    FOR(i,0,n){
        int x,t,a,b;
        cin >> x >> t >> a >> b;
        vec.pb({{t,x},{a,b}});
    }
    sort(vec.begin(),vec.end(),help);
    WL(q){
        int l,y;
        cin >> l >> y;
        int mini[n+2];
        FOR(i,0,n+2){
            mini[i] = 1e18;
        }
        FOR(i,0,n){
            int s = vec[i].second.first;
            int e = vec[i].second.second;
            if(s <= y && y <= e){
                int pos = vec[i].first.second;
                int type = vec[i].first.first;
                remin(mini[type],abs(pos-l));
            }
        }
        int maxi = 0;
        FOR(i,1,k+1){
            if(mini[i] == 1e18){
                cout << "-1" << endl;
                goto here;
            }
            remax(maxi,mini[i]);
        }
        cout << maxi << endl;
        here:
        int x;
    }
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}

Compilation message

new_home.cpp: In function 'void solve()':
new_home.cpp:103:13: warning: unused variable 'x' [-Wunused-variable]
         int x;
             ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5082 ms 16852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 182 ms 19520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -