Submission #299440

#TimeUsernameProblemLanguageResultExecution timeMemory
299440FlashGamezzzJakarta Skyscrapers (APIO15_skyscraper)Java
Compilation error
0 ms0 KiB
#include <iostream> #include <cstdlib> #include <cstdio> #include <fstream> #include <algorithm> #include <string> #include <utility> #include <vector> #include <unordered_set> #include <unordered_map> using namespace std; bool done[30000] = {}; int n, m, d0, d1, ans = -1; unordered_set<int> doges[30000]; unordered_map<int, int> dists; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for (int i = 0; i < m; i++){ int a, b; cin >> a >> b; if (i == 0) d0 = a; if (i == 1) d1 = a; doges[a].insert(b); } for (int i = 0; i < n; i++){ dists.insert(make_pair(i, 30001)); } dists[d0] = 0; while (true){ int i = -1, md = 30001; for (unordered_map<int, int>::iterator it = dists.begin(); it != dists.end(); it++){ if (it->second < md){ md = it->second; i = it->first; } } if (i == -1){ break; } if (i == d1){ ans = dists[i]; break; } for (int p : doges[i]){ for (long ni = i % p; ni < n; ni+=p){ if (!done[ni] && dists[ni] > dists[i] + abs((i-ni)/p)){ dists[ni] = dists[i] + abs((i-ni)/p); } } } dists.erase(i); done[i] = true; } cout << ans << endl; }

Compilation message (stderr)

skyscraper.java:1: error: illegal character: '#'
#include <iostream>
^
skyscraper.java:1: error: class, interface, or enum expected
#include <iostream>
         ^
skyscraper.java:2: error: illegal character: '#'
#include <cstdlib>
^
skyscraper.java:3: error: illegal character: '#'
#include <cstdio>
^
skyscraper.java:4: error: illegal character: '#'
#include <fstream>
^
skyscraper.java:5: error: illegal character: '#'
#include <algorithm>
^
skyscraper.java:6: error: illegal character: '#'
#include <string>
^
skyscraper.java:7: error: illegal character: '#'
#include <utility>
^
skyscraper.java:8: error: illegal character: '#'
#include <vector>
^
skyscraper.java:9: error: illegal character: '#'
#include <unordered_set>
^
skyscraper.java:10: error: illegal character: '#'
#include <unordered_map>
^
skyscraper.java:14: error: class, interface, or enum expected
bool done[30000] = {};
^
skyscraper.java:15: error: class, interface, or enum expected
int n, m, d0, d1, ans = -1;
^
skyscraper.java:16: error: class, interface, or enum expected
unordered_set<int> doges[30000];
^
skyscraper.java:17: error: class, interface, or enum expected
unordered_map<int, int> dists;
^
skyscraper.java:20: error: class, interface, or enum expected
int main(){
^
skyscraper.java:22: error: class, interface, or enum expected
	cin.tie(NULL);
	^
skyscraper.java:23: error: class, interface, or enum expected
	cin >> n >> m;
	^
skyscraper.java:24: error: class, interface, or enum expected
	for (int i = 0; i < m; i++){
	^
skyscraper.java:24: error: class, interface, or enum expected
	for (int i = 0; i < m; i++){
	                ^
skyscraper.java:24: error: class, interface, or enum expected
	for (int i = 0; i < m; i++){
	                       ^
skyscraper.java:25: error: class, interface, or enum expected
		int a, b; cin >> a >> b;
		          ^
skyscraper.java:26: error: class, interface, or enum expected
		if (i == 0) d0 = a;
		^
skyscraper.java:27: error: class, interface, or enum expected
		if (i == 1) d1 = a;
		^
skyscraper.java:28: error: class, interface, or enum expected
		doges[a].insert(b);
		^
skyscraper.java:29: error: class, interface, or enum expected
	}
	^
skyscraper.java:30: error: class, interface, or enum expected
	for (int i = 0; i < n; i++){
	                ^
skyscraper.java:30: error: class, interface, or enum expected
	for (int i = 0; i < n; i++){
	                       ^
skyscraper.java:32: error: class, interface, or enum expected
	}
	^
skyscraper.java:34: error: class, interface, or enum expected
	while (true){
	^
skyscraper.java:36: error: class, interface, or enum expected
		for (unordered_map<int, int>::iterator it = dists.begin(); it != dists.end(); it++){
		^
skyscraper.java:36: error: class, interface, or enum expected
		for (unordered_map<int, int>::iterator it = dists.begin(); it != dists.end(); it++){
		                                                           ^
skyscraper.java:36: error: class, interface, or enum expected
		for (unordered_map<int, int>::iterator it = dists.begin(); it != dists.end(); it++){
		                                                                              ^
skyscraper.java:38: error: class, interface, or enum expected
				md = it->second; i = it->first;
				                 ^
skyscraper.java:39: error: class, interface, or enum expected
			}
			^
skyscraper.java:43: error: class, interface, or enum expected
		}
		^
skyscraper.java:46: error: class, interface, or enum expected
			break;
			^
skyscraper.java:47: error: class, interface, or enum expected
		}
		^
skyscraper.java:49: error: class, interface, or enum expected
			for (long ni = i % p; ni < n; ni+=p){
			                      ^
skyscraper.java:49: error: class, interface, or enum expected
			for (long ni = i % p; ni < n; ni+=p){
			                              ^
skyscraper.java:52: error: class, interface, or enum expected
				}
				^
skyscraper.java:56: error: class, interface, or enum expected
		done[i] = true;
		^
skyscraper.java:57: error: class, interface, or enum expected
	}
	^
skyscraper.java:59: error: class, interface, or enum expected
}
^
44 errors