QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#371636 | #6406. Stage Clear | zhoudashuai | WA | 0ms | 3588kb | C++14 | 1.2kb | 2024-03-30 14:37:30 | 2024-03-30 14:37:30 |
Judging History
answer
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<bitset>
#include<unordered_map>
#include<iomanip>
#define endl '\n'
#define pb push_back
#define debug(x) cout<<x<<endl;
#define me(a,x) memset(a,x,sizeof(a))
#define L(i,j,k) for(int i=(j);i<=(k);++i)
#define R(i,j,k) for(int i=(j);i>=(k);--i)
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int ,int > PII;
typedef unsigned long long ull;
int n,m;
vector<int> v[110];
int a[110],b[110],st[110];
struct node{
int a,b,c;
friend bool operator<(node a,node b){
if(a.c==b.c)return a.a>b.a;
return a.c>b.c;
}
}t[110];
int bfs(int u){
priority_queue<node> q;
q.push({0,u,0});
int res=0;
while(!q.empty()){
int u=q.top().b;
q.pop();
if(st[u])continue;
st[u]=1;
for(int i=0;i<v[u].size();i++){
int j=v[u][i];
res+=b[j]-a[j];
q.push({a[j],j,b[j]-a[j]});
}
}
return res;
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n>>m;
L(i,2,n){
cin>>a[i]>>b[i];
}
L(i,1,m){
int x,y;cin>>x>>y;
v[x].pb(y);
}
cout<<bfs(1);
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
input:
4 4 4 2 5 3 2 6 1 2 1 3 2 4 3 4
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3588kb
input:
15 14 254040392438309 117083115436273 500005748229691 557255157630172 821034233718230 865199673774998 659892147898798 987564141425694 81172575487567 811635577877255 751768357864605 341103322647288 454926350150218 140191090713900 921608121471585 659295670987251 223751724062143 505619245326640 8907765...
output:
-1658955468200605
result:
wrong answer 1st numbers differ - expected: '1665396301509143', found: '-1658955468200605'