QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#391584 | #3788. Funny Car Racing | ucup-team1251 | 0 | 40ms | 8584kb | C++20 | 1.8kb | 2024-04-16 17:17:07 | 2024-04-16 17:17:07 |
Judging History
answer
#include<bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define pre(x,a,b) for(int x=a;x>=b;x--)
#define endl "\n"
#define pb push_back
#define ll long long
#define int long long
#define pii pair<ll,ll>
#define psi pair<string, ll>
#define de cout<<1;
#define mem(a,x) memset(a,x,sizeof a)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int mod1=998244353;
const int mod2=1e9+7;
const int INF=1e18;
const int N = 1e6 + 60;
int number;
int n,m,s,te,idx;
struct we{
int t,id;
bool operator <(const we &k)const{
return k.t<t;
}
};
int dis[500];
struct wwe{
int w,a,b,t;
};
vector<wwe>ve[305];
int c[500];
void bfs()
{
for(int i=1;i<=n;i++)dis[i]=1e18,c[i]=0;
dis[s]=0;
priority_queue<we>q;
q.push({0,s});
while(q.size()){
we now=q.top();
q.pop();
if(c[now.id])continue;
c[now.id]=1;
for(auto [j,a,b,p]:ve[now.id]){
int tt=dis[now.id];
int mm=tt%(a+b);
if(mm<a&&mm+p<=a&&dis[now.id]+p<dis[j]){
dis[j]=dis[now.id]+p;
q.push({dis[j],j});
}
else if(p<=a&&dis[now.id]+(a+b-mm+p)<dis[j]){
dis[j]=dis[now.id]+(a+b-mm+p);
q.push({dis[j],j});
}
}
}
//cout<<dis[2];
cout << "Case " << idx<<": ";
cout<<dis[te]<<"\n";
}
void solve()
{
while(cin >> n >> m>>s>>te)
{
idx++;
for(int i=1;i<=m;i++){
int l,r,a,b,t;
cin>>l>>r>>a>>b>>t;
ve[l].push_back({r,a,b,t});
ve[r].push_back({l,a,b,t});
}
bfs();
for(int i=1;i<=n;i++)ve[i].clear();
}
}
signed main()
{
IOS;
int _;
//scanf("%d", &_);
_ = 1;
while(_ -- )
{
number++;
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 40ms
memory: 8584kb
input:
155 9507 117 14 19 18 2 123 1 100 97 4 155 3 121 120 1 140 1 5 8 1 121 1 69 66 2 107 2 151 150 2 190 1 68 69 1 101 1 61 60 2 126 1 124 127 2 160 3 59 55 5 133 4 66 67 1 189 1 94 96 2 108 2 65 63 2 181 2 44 48 1 130 1 28 29 1 180 1 5 6 1 107 1 29 28 1 120 1 142 140 4 152 2 46 45 2 113 1 85 88 6 163 3...
output:
Case 1: 158 Case 2: 689 Case 3: 847 Case 4: 172 Case 5: 445 Case 6: 379 Case 7: 154 Case 8: 429 Case 9: 343 Case 10: 176 Case 11: 254 Case 12: 220 Case 13: 835 Case 14: 514 Case 15: 167 Case 16: 180 Case 17: 264 Case 18: 355 Case 19: 347 Case 20: 194 Case 21: 192 Case 22: 406 Case 23: 561 Case 24: 3...
result:
wrong answer 1st lines differ - expected: 'Case 1: 249', found: 'Case 1: 158'