QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#476395 | #603. 单源最短路径 | WrongAnswer_90# | 100 ✓ | 1ms | 4324kb | C++17 | 4.5kb | 2024-07-13 19:14:57 | 2024-07-13 19:14:57 |
Judging History
answer
#include<bits/stdc++.h>
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define ll long long
#define lll __int128
#define fi first
#define se second
#define e emplace
#define eb emplace_back
#define db double
#define ef emplace_front
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vp vector<pii>
#define mp make_pair
//#define LOCALJUDGE
#define int ll
bool ST;
static const ll MOD=998244353,Phi=998244352,inv2=499122177,Root=3,iRoot=332748118;
static const ll inf=1073741823,INF=4557430888798830399;
static const double eps=1e-8,pi=3.1415926535;
char in[1<<20],*p1=in,*p2=in;
using namespace std;
// #define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,1<<20,stdin),p1==p2)?EOF:*p1++)
struct tup{int x,y,z;tup(int X=0,int Y=0,int Z=0){x=X,y=Y,z=Z;}};
namespace FastIO
{
template<typename T> inline void write(T x,char ch=' ')
{
if(is_same<char,T>::value)putchar(x);
else
{
if(x<0)x=-x,putchar('-');
static char st[50];int top=0;
do{st[top++]=x%10+'0',x/=10;}while(x);
while(top)putchar(st[--top]);
}
ch!='~'?putchar(ch):0;
}
inline void write(const char*x,char ch=' ')
{
for(int i=0;x[i]!='\0';++i)putchar(x[i]);
ch!='~'?putchar(ch):0;
}
inline void read(char&s){do s=getchar();while(s=='\n'||s==' ');}
inline void read(char s[])
{
int len=0;char st;
do st=getchar();while(st=='\n'||st==' ');
s[++len]=st,st=getchar();
while(st!='\n'&&st!=' ')s[++len]=st,st=getchar();
s[++len]='\0';
}
template<typename T> inline void read(T &s)
{
s=0;char ch=getchar();
while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
bool tf=(ch=='-')&&(ch=getchar());
while((ch>='0')&&(ch<='9'))s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
s=(tf?-s:s);
}
template<typename T1,typename T2> inline void read(pair<T1,T2> &s){read(s.fi),read(s.se);}
template<typename T,typename...Args> inline void write(T x,Args...args){write(x,'~'),write(args...);}
template<typename T,typename...Args> inline void read(T&x,Args&...args){read(x),read(args...);}
}
using namespace FastIO;
namespace MTool
{
inline int Cadd(int a,int b){return (ll)a+b>=MOD?(ll)a+b-MOD:a+b;}
inline int Cdel(int a,int b){return a-b<0?a-b+MOD:a-b;}
inline int Cmul(int a,int b){return 1ll*a*b%MOD;}
inline int sqr(int a){return 1ll*a*a%MOD;}
inline void Madd(int&a,int b){a=((ll)a+b>=MOD?(ll)a+b-MOD:a+b);}
inline void Mdel(int&a,int b){a=(a-b<0?a-b+MOD:a-b);}
inline void Mmul(int&a,int b){a=1ll*a*b%MOD;}
template<typename T> inline bool Mmax(T&a,T b){return a<b?a=b,1:0;}
template<typename T> inline bool Mmin(T&a,T b){return a>b?a=b,1:0;}
template<typename...Args> inline void Madd(int&a,int b,Args...args){Madd(a,b),Madd(a,args...);}
template<typename...Args> inline void Mmul(int&a,int b,Args...args){Mmul(a,b),Mmul(a,args...);}
template<typename...Args> inline void Mdel(int&a,int b,Args...args){Mdel(a,b),Mdel(a,args...);}
template<typename...Args> inline int Cadd(int a,int b,Args...args){return Cadd(Cadd(a,b),args...);}
template<typename...Args> inline int Cmul(int a,int b,Args...args){return Cmul(Cmul(a,b),args...);}
template<typename...Args> inline int Cdel(int a,int b,Args...args){return Cdel(Cdel(a,b),args...);}
template<typename...Args,typename T> inline bool Mmax(T&a,T b,Args...args){return Mmax(a,b)|Mmax(a,args...);}
template<typename...Args,typename T> inline bool Mmin(T&a,T b,Args...args){return Mmin(a,b)|Mmin(a,args...);}
inline int power(int x,int y){int s=1;for(;y;y>>=1,Mmul(x,x))if(y&1)Mmul(s,x);return s;}
}
using namespace MTool;
namespace WrongAnswer_90
{
int cnt,n,m,S,T,head[2510],to[13010],v[13010],nex[13010],d[2510];
bool vis[2510];
inline void add(int x,int y,int z){to[++cnt]=y,nex[cnt]=head[x],head[x]=cnt,v[cnt]=z;}
inline void mian()
{
read(n,m,S,T);int x,y,z;priority_queue<pii> q;
assert(n<=2500),assert(m<=6200);
for(int i=1;i<=m;++i)read(x,y,z),add(x,y,z),add(y,x,z);
memset(d,127,sizeof(d)),d[S]=0,q.e(mp(0,S));
while(!q.empty())
{
int nw=q.top().se;q.pop();
if(vis[nw])continue;vis[nw]=1;
for(int i=head[nw];i;i=nex[i])
if(Mmin(d[to[i]],d[nw]+v[i]))
q.e(mp(-d[to[i]],to[i]));
}
write(d[T]);
}
}
bool ED;
signed main()
{
#ifdef LOCALJUDGE
freopen("ex_mod5.in","r",stdin);
freopen("1.out","w",stdout);
#endif
double st=clock();
WrongAnswer_90::mian();
double ed=clock();
#ifndef LOCALJUDGE
cerr<<endl;
#endif
cerr<<"Time: "<<ed-st<<" ms\n";
#ifdef LOCALJUDGE
cerr<<" ";
#endif
cerr<<"Memory: "<<abs(&ST-&ED)/1024.0/1024.0<<" MB\n";
return 0;
}
详细
Test #1:
score: 10
Accepted
time: 0ms
memory: 3848kb
input:
7 11 5 4 2 4 2 1 4 3 7 2 2 3 4 3 5 7 5 7 3 3 6 1 1 6 3 4 2 4 3 5 6 3 7 2 1
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 10
Accepted
time: 0ms
memory: 3904kb
input:
10 20 9 4 5 6 308 8 10 696 4 2 569 8 6 471 1 2 874 5 3 130 4 5 804 8 9 89 10 4 717 10 9 41 7 6 998 1 6 639 7 9 650 7 8 339 3 1 597 9 1 622 7 10 2 5 1 4 1 4 372 1 10 163
output:
576
result:
ok 1 number(s): "576"
Test #3:
score: 10
Accepted
time: 0ms
memory: 3968kb
input:
20 43 11 19 8 14 569 17 13 859 11 14 571 18 14 583 14 5 569 9 1 342 14 6 397 14 17 640 12 1 331 19 12 999 16 1 203 19 6 493 9 14 645 7 4 118 15 6 218 15 20 164 13 16 737 1 15 548 1 17 478 4 15 286 4 17 964 12 14 165 15 7 759 1 5 976 19 11 491 15 11 286 14 1 889 10 17 852 15 16 6 20 3 563 12 7 538 11...
output:
491
result:
ok 1 number(s): "491"
Test #4:
score: 10
Accepted
time: 0ms
memory: 4008kb
input:
50 122 14 3 49 4 977 17 16 209 10 8 573 14 45 989 41 49 988 11 13 548 34 46 367 29 35 30 13 16 220 50 11 280 42 16 608 46 48 423 48 9 381 27 13 514 26 2 725 38 1 10 33 18 688 19 47 750 36 18 650 49 47 393 14 6 688 13 29 387 22 11 10 45 37 974 9 12 926 35 49 776 44 33 993 34 1 592 33 39 409 34 37 858...
output:
1215
result:
ok 1 number(s): "1215"
Test #5:
score: 10
Accepted
time: 0ms
memory: 3920kb
input:
100 251 88 95 90 39 170 75 71 718 38 37 51 92 86 622 29 46 790 85 43 175 14 65 614 2 97 123 72 28 919 9 89 158 63 89 159 55 30 297 76 4 267 94 93 56 96 85 293 69 65 539 58 49 281 85 14 997 98 15 693 72 39 73 90 47 513 100 53 642 96 28 897 14 73 790 26 14 289 90 52 699 91 84 283 56 32 480 71 24 151 9...
output:
969
result:
ok 1 number(s): "969"
Test #6:
score: 10
Accepted
time: 0ms
memory: 4080kb
input:
250 610 204 239 1 247 593 247 65 111 191 153 113 189 37 316 93 62 988 93 89 888 21 130 778 129 107 123 47 228 487 100 57 980 163 113 267 212 101 950 166 113 5 6 53 907 118 241 295 183 186 208 170 206 88 50 84 546 50 51 545 24 233 875 65 233 805 10 82 432 137 82 232 10 71 332 240 97 44 108 58 496 57 ...
output:
1544
result:
ok 1 number(s): "1544"
Test #7:
score: 10
Accepted
time: 1ms
memory: 4112kb
input:
500 1229 5 23 465 257 101 425 207 131 355 233 664 250 266 163 379 191 152 281 465 611 218 473 40 455 480 812 59 427 310 126 465 18 290 242 648 250 356 755 237 211 562 379 468 44 205 291 213 199 474 242 6 282 434 46 203 171 11 460 427 489 165 21 368 387 12 387 349 105 275 21 596 481 298 962 341 329 9...
output:
1252
result:
ok 1 number(s): "1252"
Test #8:
score: 10
Accepted
time: 0ms
memory: 4116kb
input:
1000 2450 925 987 674 703 724 780 787 532 101 418 143 102 463 431 103 481 109 104 496 854 105 497 593 106 507 493 107 508 875 565 789 511 800 565 119 108 578 499 255 9 123 872 862 1 745 991 369 788 373 241 277 987 124 278 382 125 291 601 126 387 332 127 366 72 128 378 511 129 369 389 210 799 798 42 ...
output:
762
result:
ok 1 number(s): "762"
Test #9:
score: 10
Accepted
time: 1ms
memory: 4268kb
input:
2000 4862 1935 306 1726 751 709 1643 1852 159 1388 1503 791 1881 1033 332 1360 1713 750 1656 1855 868 1439 573 758 1923 1333 593 1577 1742 112 105 1816 965 800 1560 130 10 1856 76 1735 1926 259 643 1902 301 1140 1301 475 580 180 860 1972 1236 383 238 722 242 1937 1372 282 1468 1316 95 64 522 696 132...
output:
1075
result:
ok 1 number(s): "1075"
Test #10:
score: 10
Accepted
time: 1ms
memory: 4324kb
input:
2500 6071 1760 669 2310 2380 17 2411 2373 371 2478 2411 405 2328 2492 300 538 2483 342 2310 2380 492 2262 2224 474 2202 2199 410 2215 2186 275 2154 2138 462 2186 2003 41 2121 2124 364 2029 2030 198 2125 1983 256 2042 2071 495 1895 1880 420 1862 1747 112 1963 1890 172 1890 1959 296 1926 1650 112 1651...
output:
1159
result:
ok 1 number(s): "1159"