답안 #88591

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88591 2018-12-06T23:10:21 Z amiratou Roller Coaster Railroad (IOI16_railroad) C++14
0 / 100
230 ms 25960 KB
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define fi first
#define se second
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vv vector<vector<int> >
#define pb push_back
#define INF LLONG_MAX
using namespace std;
vector<int> limit,exitsp;
int n;
set<pair<int,int> > myset,original;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
    n = (int) s.size();
    int maxi,maxval=0,mini,minval=INT_MAX;
    for (int i = 0; i < n; ++i)
    {
    	myset.insert({s[i],i});
    	if(minval>s[i]){
    		minval=s[i];
    		mini=i;
    	}
    	if(maxval<t[i]){
    		maxval=t[i];
    		maxi=i;
    	}
    }
    if(maxi==mini){
    	auto temp=myset.begin();
    	temp++;
    	mini=temp->se;
    	myset.erase(temp);
    }
    else myset.erase(myset.begin());
    myset.erase(myset.find({s[maxi],maxi}));
    int curr=t[mini];
    while(!myset.empty()){
    	auto search=myset.lower_bound({curr,0});
    	if(search->fi!=curr&&search==myset.end())return INF-5;
    	if(search->fi!=curr)
    		search++;
    	curr=t[search->se];
    	myset.erase(search);
    }
    return 0;
}

Compilation message

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:43:35: warning: 'maxi' may be used uninitialized in this function [-Wmaybe-uninitialized]
     myset.erase(myset.find({s[maxi],maxi}));
                                   ^
railroad.cpp:36:5: warning: 'mini' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(maxi==mini){
     ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 2
2 Correct 2 ms 380 KB n = 2
3 Correct 2 ms 440 KB n = 2
4 Correct 2 ms 440 KB n = 2
5 Correct 2 ms 456 KB n = 2
6 Incorrect 2 ms 500 KB answer is not correct: 0 instead of 523688153
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 2
2 Correct 2 ms 380 KB n = 2
3 Correct 2 ms 440 KB n = 2
4 Correct 2 ms 440 KB n = 2
5 Correct 2 ms 456 KB n = 2
6 Incorrect 2 ms 500 KB answer is not correct: 0 instead of 523688153
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 230 ms 25960 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 2
2 Correct 2 ms 380 KB n = 2
3 Correct 2 ms 440 KB n = 2
4 Correct 2 ms 440 KB n = 2
5 Correct 2 ms 456 KB n = 2
6 Incorrect 2 ms 500 KB answer is not correct: 0 instead of 523688153
7 Halted 0 ms 0 KB -