Submission #24057

# Submission time Handle Problem Language Result Execution time Memory
24057 2017-05-30T04:59:03 Z gs14004 Roller Coaster Railroad (IOI16_railroad) C++11
0 / 100
543 ms 30132 KB
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;

// s[i] -> t[i]
// inf amount of i -> i+1, if needed
// outdegree = -1
// indegree = 1
// ok if eulerable in every comp.

map<int, int> mp;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
	vector<pi> v;
    int n = (int) s.size();
    for(int i=0; i<n; i++) mp[s[i]]--, mp[t[i]]++;
  	bool shortage = 0;
  	for(auto &i : mp) v.push_back(pi(i.first, i.second));
  	for(int i=0; i<v.size(); i++){
        v[i+1].second -= v[i].second;
      	if(v[i].second < 0){
          	if(shortage) return 1;
          	shortage = 1;
        }
    }
    return 0;
}

Compilation message

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:19:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i=0; i<v.size(); i++){
                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB n = 2
2 Correct 0 ms 2024 KB n = 2
3 Correct 0 ms 2024 KB n = 2
4 Correct 0 ms 2024 KB n = 2
5 Incorrect 0 ms 2024 KB answer is not correct: 1 instead of 0
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB n = 2
2 Correct 0 ms 2024 KB n = 2
3 Correct 0 ms 2024 KB n = 2
4 Correct 0 ms 2024 KB n = 2
5 Incorrect 0 ms 2024 KB answer is not correct: 1 instead of 0
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 543 ms 30132 KB answer is not correct: 1 instead of 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB n = 2
2 Correct 0 ms 2024 KB n = 2
3 Correct 0 ms 2024 KB n = 2
4 Correct 0 ms 2024 KB n = 2
5 Incorrect 0 ms 2024 KB answer is not correct: 1 instead of 0
6 Halted 0 ms 0 KB -