Submission #399334

# Submission time Handle Problem Language Result Execution time Memory
399334 2021-05-05T15:23:44 Z MeGustaElArroz23 Jakarta Skyscrapers (APIO15_skyscraper) C++14
0 / 100
1 ms 208 KB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;

int main(){
    ll l,n;
    cin >> l >> n;
    vii v(n);
    for (ll i=0;i<n;i++) cin >> v[i].first >> v[i].second;
    vvii conexiones(n);
    
    for (ll i=0;i<n;i++){
        pii x=v[i];
        for (ll j=0;j<n;j++){
            pii y=v[j];
            if (x==y) continue;
            if (y.first%x.second==x.first%x.second) conexiones[i].push_back(pii{abs(x.first-y.first)/x.second,j});
        }
    }
    priority_queue<pii> cola;
    cola.push(pii{0,0});
    bool T=true;
    vi porvisitar(n,true);
    while (cola.size()){
        pii x=cola.top();
        cola.pop();
        if (porvisitar[x.second]){
            porvisitar[x.second]=false;
            if (x.second==1){
                T=false;
                cout << -x.first << '\n';
                break;
            }
            for (pii y:conexiones[x.second]){
                cola.push(pii{x.first-y.first,y.second});
            }
        }
    }
    if (T) cout << -1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 208 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -