Submission #106186

# Submission time Handle Problem Language Result Execution time Memory
106186 2019-04-17T08:00:00 Z OpenTheWindow Gap (APIO16_gap) C++14
Compilation error
0 ms 0 KB
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>

#include"gap.h"

using namespace std;


long long findGap(int T, int N){
	long long ans = 0;

	if(T == 1){
		vector<long long> a;

		long long s = 0, t = 1000000000000000000LL;
		while (true)
		{
			long long mn, mx;

			if(a.size() == N) break;

			if(s > t) break;
			MinMax(s, t, &mn, &mx);

			if(mn == -1) break;

			if(mn < mx){
				a.push_back(mn);
				a.push_back(mx);

				s = mn + 1;
				t = mx - 1;

			}
			if(mn == mx){
				a.push_back(mn);
				break;
			}
		}

		sort(a.begin(), a.end());

		ans = 0;

		for(int i=0; i<N-1; i++){
			ans = max(ans, a[i+1] - a[i]);
		}


	}
	else{

		vector<long long> a;

		long long ms = 0, mt = 1000000000000000000LL;
		long long mn, mx;

		MinMax(s, t, &mn, &mx);

		a.push_back(mn);
		a.push_back(mx);

		long long s = mn + 1, t = mn + 2;
		while (true)
		{
			if(a.size() == N) break;

			MinMax(s, t, &mn, &mx);

			if(mn < mx){
				a.push_back(mn);
				a.push_back(mx);
			}
			if(mn == mx){
				a.push_back(mn);
			}

			s = t + 1;
			t = s + 2;
		}

		sort(a.begin(), a.end());

		ans = 0;

		for(int i=0; i<N-1; i++){
			ans = max(ans, a[i+1] - a[i]);
		}
	}



	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(a.size() == N) break;
       ~~~~~~~~~^~~~
gap.cpp:65:10: error: 's' was not declared in this scope
   MinMax(s, t, &mn, &mx);
          ^
gap.cpp:65:10: note: suggested alternative: 'ms'
   MinMax(s, t, &mn, &mx);
          ^
          ms
gap.cpp:65:13: error: 't' was not declared in this scope
   MinMax(s, t, &mn, &mx);
             ^
gap.cpp:65:13: note: suggested alternative: 'mt'
   MinMax(s, t, &mn, &mx);
             ^
             mt
gap.cpp:73:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(a.size() == N) break;
       ~~~~~~~~~^~~~
gap.cpp:62:13: warning: unused variable 'ms' [-Wunused-variable]
   long long ms = 0, mt = 1000000000000000000LL;
             ^~
gap.cpp:62:21: warning: unused variable 'mt' [-Wunused-variable]
   long long ms = 0, mt = 1000000000000000000LL;
                     ^~