Submission #923689

# Submission time Handle Problem Language Result Execution time Memory
923689 2024-02-07T15:14:10 Z Isam Alias (COCI21_alias) C++17
50 / 70
33 ms 604 KB
#include<bits/stdc++.h>

#define speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define file freopen("condense2.in", "r", stdin), freopen("condense2.out", "w", stdout);
#define eb emplace_back
#define all(x) x.begin(), x.end()

using namespace std;

const int sz = 1001;

int n, m, Q, cnt(1), t, d[sz];
vector<array<int, 2>> g[sz];
string a, b;
map<string, int> mp;

priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;

inline void Dijkstra(int &s){
	q.push({s, 0});
	d[s] = 0;
	while(!q.empty()){
		int node = q.top().first, dist = q.top().second;
		q.pop();
		if(dist > d[node]) continue;
		for(auto &to : g[node]){
			int toto{to[0]}, len{to[1]};
			if(d[toto] > dist + len){
				d[toto] = dist + len;
				q.push({toto, d[toto]});
			}
		}
	}
	return;
}

inline void init(){
	for(register int i = 1; i <= n; ++i) d[i] = (int)(1e9);
	return;
}


int main(){
	speed;
	cin >> n >> m;
	for(register int i = 1, u, v; i <= m; ++i){
		cin >> a >> b >> t;;
		if(!mp[a]) mp[a] = cnt++;
		if(!mp[b]) mp[b] = cnt++;
		u = mp[a], v = mp[b];
		g[u].eb((array<int, 2>){v, t});
	}
	cin >> Q;
	while(Q--){
		cin >> a >> b;
		if(!mp[a]) mp[a] = cnt++;
		if(!mp[b]) mp[b] = cnt++;
		init();
		Dijkstra(mp[a]);
		if(d[mp[b]] == (int)1e9) cout << "Roger" << '\n';
		else cout << d[mp[b]] << '\n';
	}
	return 0;
}

Compilation message

alias.cpp: In function 'void init()':
alias.cpp:38:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   38 |  for(register int i = 1; i <= n; ++i) d[i] = (int)(1e9);
      |                   ^
alias.cpp: In function 'int main()':
alias.cpp:46:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   46 |  for(register int i = 1, u, v; i <= m; ++i){
      |                   ^
alias.cpp:46:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   46 |  for(register int i = 1, u, v; i <= m; ++i){
      |                          ^
alias.cpp:46:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   46 |  for(register int i = 1, u, v; i <= m; ++i){
      |                             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 21 ms 348 KB Output is correct
4 Incorrect 33 ms 604 KB Output isn't correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Incorrect 3 ms 508 KB Output isn't correct