Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
​
​
​
​
​
int V,E,Tmax;
int edge[401][401];
int dis[401][401];
int dep[401][401];
vector< pair<int,int> > G[401];
vector<int> Nnew,new_id,dst;
// 無向！
​
void init(){
	FOR(i,0,401)
		FOR(j,0,401)
			dis[i][j]=MOD;
}
​
void input(){
	int u,v,d;
	cin >> V >> E;
	FOR(i,0,E){
		cin >> u >> v >> d;
		edge[u][v]=dis[u][v]=d;
		edge[v][u]=dis[v][u]=d;
		G[u].push_back(make_pair(v,d));
		G[v].push_back(make_pair(u,d));
	}
	cin >> Tmax;
	Nnew.resize(Tmax+1,0);
	new_id.resize(Tmax+1,0);
	dst.resize(Tmax+1,0);
	FOR(i,1,Tmax+1){
		cin >> Nnew[i];
		if(Nnew[i]){
			cin >> new_id[i] >> dst[i];
		}
	}
}
​
void calc_dep(int st){
	dep[st][st] = 1;
	queue<int> q;
	q.push(st);
	while(q.size()){
		int now = q.front();
		q.pop();
		for(auto to:G[now]){
			if( edge[now][to.first] && dep[st][to.first]==0 ){
				dep[st][to.first] = dep[st][now] + 1;
				q.push(to.first);
			}
		}
	}
}
​
void gogogo(const vector<int> &r,int& time){
	FOR(i,0,r.size()-1){
		int len = edge[r[i]][r[i+1]];
		FOR(j,0,len){
			if(time>Tmax)return;
			cout << r[i+1] << endl;
			time++;
		}
	}
}
​
​
int main(){
	init();
	input();
	FOR(i,1,V+1)
	{
		calc_dep(i);
	}
	//cout << 99999 << endl;
​
	int now_t = 1;
	int bf1_t = 1;
	set<int> wait;
	vector<int> wait_cnt(V+1,0);
	while(now_t<=Tmax){
		if(Nnew[now_t]){
			wait.insert(dst[now_t]);
			wait_cnt[dst[now_t]]++;
		}
		if(wait.size()==0){
			now_t++;
			cout << -1 << endl;
			continue;
		}
		int to = *wait.begin();
		vector<int> road;
		road.push_back(to);
		int now = to;
		while(1){
			int dep_min = V+1;
			int nxnow;
			for(auto nx:G[now]){
				if(dep[1][nx.first]<dep_min){
					dep_min = dep[1][nx.first];
					nxnow = nx.first;
				}
			}
			road.push_back(nxnow);
			now = nxnow;
			if(now==1)break;
		}
		reverse(road.begin(),road.end());
		gogogo(road,now_t);
		reverse(road.begin(),road.end());
		gogogo(road,now_t);
		for(auto del:road){
			wait.erase(del);
			wait_cnt[del] = 0;
		}
		gogogo(road,now_t);
		while(bf1_t<now_t){
			bf1_t++;
			if(Nnew[bf1_t]){
				wait.insert(dst[bf1_t]);
				wait_cnt[dst[bf1_t]]++;
			}
		}
	}
​
​
}


Compiler output:
a.cc:19:1: error: '\U0000200b' does not name a type
   19 | ​
      |  
a.cc:31:1: error: '\U0000200b' does not name a type
   31 | ​
      |  
a.cc:37:1: error: '\U0000200b' does not name a type
   37 | ​
      |  
a.cc:59:1: error: '\U0000200b' does not name a type
   59 | ​
      |  
a.cc:75:1: error: '\U0000200b' does not name a type
   75 | ​
      |  
a.cc:86:1: error: '\U0000200b' does not name a type
   86 | ​
      |