| Task: | Ping |
| Sender: | Przemyslaw Uznanski |
| Submission time: | 2015-09-09 17:15:29 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.06 s | details |
| #2 | ACCEPTED | 0.07 s | details |
| #3 | WRONG ANSWER | 0.10 s | details |
| #4 | ACCEPTED | 0.11 s | details |
| #5 | WRONG ANSWER | 0.10 s | details |
| #6 | ACCEPTED | 0.09 s | details |
| #7 | ACCEPTED | 0.09 s | details |
| #8 | ACCEPTED | 0.18 s | details |
| #9 | ACCEPTED | 0.20 s | details |
| #10 | WRONG ANSWER | 0.07 s | details |
| #11 | WRONG ANSWER | 0.09 s | details |
| #12 | WRONG ANSWER | 0.08 s | details |
| #13 | ACCEPTED | 0.08 s | details |
| #14 | ACCEPTED | 0.09 s | details |
| #15 | WRONG ANSWER | 0.09 s | details |
| #16 | WRONG ANSWER | 0.09 s | details |
| #17 | WRONG ANSWER | 0.09 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:65:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d",&n,&q,&p);
^
input/code.cpp:70:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d",&u,&v,&d);
^Code
#include <cstdio>
#include <queue>
#include <algorithm>
#include <vector>
#include <set>
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define x1 first
#define x2 second.first
#define x3 second.second
#define trip(a,b,c) mp(a,mp(b,c))
using namespace std;
const int inf = 1000000007;
int n,q,p;
vector<vector<pair<int,pair<int,int> > > > G;
bool test(int thr)
{
set<pair<int,int> > pq;
int target = n-1;
vector<int> dist(n,inf);
vector<bool> done(n,false);
dist[0]=0;
pq.insert(mp(0,0));
while(!pq.empty())
{
pair<int,int> X = *pq.begin();
pq.erase(pq.begin());
int u = X.second;
int d = X.first;
if(d > p)
return false;
if(u == target)
return true;
if(done[u])
continue;
done[u]=true;
for(auto& it : G[u])
{
if(it.x3 >= thr)
continue;
int v = it.x1;
int vd = dist[u]+it.x2;
if(vd>p)
continue;
if(vd<dist[v])
{
dist[v]=vd;
pq.insert(mp(vd,v));
}
}
}
return false;
}
int main()
{
scanf("%d%d%d",&n,&q,&p);
G.resize(n);
for(int i=0;i<q;i++)
{
int u,v,d;
scanf("%d%d%d",&u,&v,&d);
u--;
v--;
G[u].pb(trip(v,d,i));
G[v].pb(trip(u,d,i));
}
int low = 0;
int high = n;
if(!test(n))
{
puts("QAQ");
return 0;
}
while(high>low+1)
{
int mid = low + (high-low)/2;
if(test(mid))
high = mid;
else
low = mid;
}
printf("%d\n",high);
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 4 5 4 1 4 5 2 1 1 4 3 2 1 3 2 ... |
| correct output |
|---|
| 4 |
| user output |
|---|
| 4 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 4 3 4 1 3 2 3 4 3 2 4 1 |
| correct output |
|---|
| QAQ |
| user output |
|---|
| QAQ |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 79228 100000 609719088 71059 11143 686695 68230 2527 877907 53438 29888 202308 3549 78720 356072 ... |
| correct output |
|---|
| 95914 |
| user output |
|---|
| QAQ |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 54105 100000 146069808 21034 33530 208067 31369 39373 438341 53601 30432 458004 44664 29661 964679 ... |
| correct output |
|---|
| 47249 |
| user output |
|---|
| 47249 |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 27534 100000 630452185 4554 20869 156656 18125 16857 129766 7327 23355 162783 12208 19586 330973 ... |
| correct output |
|---|
| 37629 |
| user output |
|---|
| QAQ |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 1896201 37633 24342 686408 21326 35599 18816 68870 92002 748527 87772 68354 816268 ... |
| correct output |
|---|
| QAQ |
| user output |
|---|
| QAQ |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 2753856 28301 86840 226813 23531 88963 140812 81527 28867 31169 81346 50536 187421 ... |
| correct output |
|---|
| QAQ |
| user output |
|---|
| QAQ |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 8894369 96437 89061 279201 93127 41538 16340 5646 70264 970395 96240 15676 526054 ... |
| correct output |
|---|
| 89568 |
| user output |
|---|
| 89568 |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 8920310 51576 49748 441411 75379 58501 720057 77269 34775 380776 45446 74022 804975 ... |
| correct output |
|---|
| 94792 |
| user output |
|---|
| 94792 |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 5000 100000 699655 4460 4283 850197 3421 2128 903580 3335 401 848289 4975 4482 241023 ... |
| correct output |
|---|
| 58358 |
| user output |
|---|
| QAQ |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 5000 100000 2906768 4100 2619 553305 4947 1462 263251 1703 4236 286383 4228 4797 635722 ... |
| correct output |
|---|
| 12392 |
| user output |
|---|
| QAQ |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 5000 100000 8525016 4452 4625 772169 4941 929 373626 2610 379 935441 3007 4 402654 ... |
| correct output |
|---|
| 16113 |
| user output |
|---|
| QAQ |
Test 13
Verdict: ACCEPTED
| input |
|---|
| 5000 100000 6672172 2548 393 274388 1269 4076 230068 24 3024 596999 4658 2589 401693 ... |
| correct output |
|---|
| 3674 |
| user output |
|---|
| 3674 |
Test 14
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 1000000000 61435 73156 809653003 31805 69457 997174565 46138 4746 664487503 77749 57316 726729812 ... |
| correct output |
|---|
| QAQ |
| user output |
|---|
| QAQ |
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| 70000 100000 389981 69496 42899 329 42449 25317 445 2446 37175 175 4791 27488 51 ... |
| correct output |
|---|
| 71694 |
| user output |
|---|
| QAQ |
Test 16
Verdict: WRONG ANSWER
| input |
|---|
| 70000 100000 7413515 66481 13331 14 34935 8021 953 66946 55602 904 49080 1580 157 ... |
| correct output |
|---|
| 82046 |
| user output |
|---|
| QAQ |
Test 17
Verdict: WRONG ANSWER
| input |
|---|
| 20000 100000 100000000 1 2 10000 2 3 10000 3 4 10000 4 5 10000 ... |
| correct output |
|---|
| 50001 |
| user output |
|---|
| QAQ |
