Submission #863878

#TimeUsernameProblemLanguageResultExecution timeMemory
863878prairie2022Railway Trip 2 (JOI22_ho_t4)C++17
Compilation error
0 ms0 KiB
for(cin >> q; q; q--){ cin >> s >> t; vector<vector<int>> way(n+1); for(int i=0; i<m; i++){ if(near(s, rail[i])) way[near(s, rail[i])].push_back(i); } vector<int> dp(n+1, -1); dp[s] = 0; int l = s, r = s; queue<int> qu; for(qu.push(s); !qu.empty() || qu.front()==t; qu.pop()){ //cout << qu.front() << " : "; for(const int &w: way[qu.front()]){ //cout << w << ' '; if(rail[w].S>r){ for(int i=r+1; i<=rail[w].S; i++){ dp[i] = dp[qu.front()]+1; qu.push(i); } r = rail[w].S; } else if(rail[w].S<l){ for(int i=l-1; i>=rail[w].S; i--){ dp[i] = dp[qu.front()]+1; qu.push(i); } l = rail[w].S; } } //cout << '\n'; } cout << dp[t] << '\n'; } return 0; }

Compilation message (stderr)

Main.cpp:1:5: error: expected unqualified-id before 'for'
    1 |     for(cin >> q; q; q--){
      |     ^~~
Main.cpp:1:19: error: 'q' does not name a type
    1 |     for(cin >> q; q; q--){
      |                   ^
Main.cpp:1:22: error: 'q' does not name a type
    1 |     for(cin >> q; q; q--){
      |                      ^
Main.cpp:34:5: error: expected unqualified-id before 'return'
   34 |     return 0;
      |     ^~~~~~
Main.cpp:35:1: error: expected declaration before '}' token
   35 | }
      | ^