只拿了15分,不知道错在哪,希望大佬能看一下。
#include<bits/stdc++.h>
using namespace std;
const int M=1e4+20;
struct youxiao{
int next,day,value;
};
struct node{
int key,val;
};
vector<youxiao> youxiaoqi[M];
int currValue[M][M];
//vector<node> currValue[M];
//pair<int,int> edges[M][M];
int n,m,ki,li,u,v,x,y,pi,qi;
int toSelect[M],mainObject[M];
void update(int i){
for(int iii=1;iii<=n;iii++){
for(int jj=0;jj<youxiaoqi[iii].size();jj++){
if (youxiaoqi[iii][jj].day<=i){
int linju = youxiaoqi[iii][jj].next;
int value = youxiaoqi[iii][jj].value;
currValue[iii][linju]-=value;
youxiaoqi[iii][jj].value=0;
}
}
}
//通信主要对象归零
for(int i=1;i<=n;i++){
mainObject[i]=0;
}
//查询对象归零
memset(toSelect,0,sizeof toSelect);
}
int main(){
//n台机器,m天
cin >>n>>m;
for(int i=0;i<m;i++){
//先更新
update(i);
//第i天
//第一行
cin >>ki;
for(int no=0;no<ki;no++){
cin >>u>>v>>x>>y;
currValue[u][v]+=x;
youxiao temp;
temp.next = v;
temp.day = i+y;
temp.value = x;
youxiaoqi[u].push_back(temp);
youxiao temp2;
temp2.next = u;
temp2.day = i+y;
temp2.value = x;
currValue[v][u]+=x;
youxiaoqi[v].push_back(temp2);
}
//第二行
cin >>li;
for(int j=0;j<li;j++){
cin >>toSelect[j];
}
//第三行
cin >>pi>>qi;
for(int j=1;j<=n;j++){
int res=0;
for(int k=1;k<=n;k++){
if(currValue[j][k]>res){
res = currValue[j][k];
mainObject[j]=k;
}
}
}
for(int j=0;j<li;j++){
int curr = toSelect[j];
cout <<mainObject[curr]<<endl;
}
if(pi==1){
int gudao = 0;
for(int one=1;one<=n;one++){
if(mainObject[one]==0) gudao++;
}
cout<<gudao<<endl;
}
if(qi==1){
int dui = 0;
int mark[n];
for(int one=1;one<=n;one++){
if(mainObject[one]==0) continue;
if(mainObject[mainObject[one]]==one) {
dui++;
};
}
dui/=2;
cout<<dui<<endl;
}
}
return 0;
}