QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#417174 | #3791. Interesting Calculator | Jay05 | 0 | 75ms | 6244kb | C++20 | 1.3kb | 2024-05-22 15:43:56 | 2024-05-22 15:43:57 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <queue>
#include <iostream>
#include <algorithm>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn=100020;
int x,y;
queue<int>f;
int h[8][maxn],visi[100005],dis[100005],cont[100005];
void cal(int s,int tt,int cost){
if(dis[tt]==dis[s]+cost&&cont[tt]>cont[s]+1){
cont[tt]=cont[s]+1;
if(!visi[tt]){
f.push(tt);
visi[tt]=1;
//TODO
}
//TODO
}else if(dis[tt]>dis[s]+cost){
dis[tt]=dis[s]+cost;
cont[tt]=cont[s]+1;
if(!visi[tt]){
f.push(tt);
visi[tt]=1;
//TODO
}
}
}
void bfs(int x,int y){
for(int i=0;i<maxn;i++){
visi[i]=0;
dis[i]=INF;
cont[i]=INF;
//TODO
}
f.push(x);
visi[x]=1;
dis[x]=0;
cont[x]=0;
while(!f.empty()){
int t=f.front();
f.pop();
for(int i=0;i<10;i++){
if(t*10+i<maxn){
cal(t,t*10+i,h[0][i]);
//TODO
}if(t+i<maxn){
cal(t,t+i,h[1][i]);
//TODO
}if(t*i<maxn){
cal(t,t*i,h[2][i]);
//TODO
}
//TODO
}
//TODO
}
}
int main(){
int cas=0;
while(~scanf("%d %d",&x,&y)){
while(!f.empty()){
f.pop();
//TODO
}
for(int i=0;i<3;i++){
for(int j=0;j<10;j++){
scanf("%d",&h[i][j]);
//TODO
}
//TODO
}
bfs(x,y);
printf("Case %d: %d %d\n",++cas,dis[y],cont[y]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 75ms
memory: 6244kb
input:
12 256 100 100 100 1 100 100 100 100 100 100 6 5 4 3 2 1 2 3 4 5 100 100 10 100 100 100 100 100 100 100 12 256 100 100 100 1 100 100 100 100 100 100 100 100 100 100 100 1 100 100 100 100 100 100 10 100 100 100 100 100 100 100 1 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 10...
output:
Case 1: 5 3 Case 2: 10 2 Case 3: 100000 5 Case 4: 49999 49999 Case 5: 555600000 5556 Case 6: 13335400 2230 Case 7: 1283637 1070 Case 8: 3263846 1050 Case 9: 63820 10 Case 10: 35178861 401 Case 11: 2475236 181 Case 12: 16128030 8770 Case 13: 39259236 1714 Case 14: 10810842 895 Case 15: 25539336 7758 ...
result:
wrong answer 1st lines differ - expected: 'Case 1: 9 4', found: 'Case 1: 5 3'