CSES - Putka Open 2015 – 1/6 - Results
Submission details
Task:Aita
Sender:
Submission time:2015-07-18 16:38:23 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions.

Code

#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

#define pii pair<int, int>
#define pll pair<long long, long long>

#define defmod 1000000007
using namespace std;


int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	ll n, k; cin >> n >> k;
	ll re[101010];
	for(int i = 0; i < n; i++){
		re[i+1] = i+1;
	}

	for(int i = 1; i <= n; i++){
		bool ok = true;
		if(i == 1){
			if(abs(re[i]-re[i+1]) < k)
				ok = false;
		}
		else if(i == n){
			if(abs(re[i]-re[i-1]) < k)
				ok = false;
		}
		else{
			if(abs(re[i]-re[i+1]) < k)
				ok = false;
			if(abs(re[i]-re[i-1]) < k)
				ok = false;
		}
		if(ok)
			continue;

		for(int j = n; j >= 1; j--){
			if(j == i)
				continue;
			bool ok2 = true;
			swap(re[i], re[j]);
			if(j < i){
				if(i == 1){
					if(abs(re[i]-re[i+1]) < k)
					ok2 = false;
				}
				else if(i == n){
					if(abs(re[i]-re[i-1]) < k)
						ok2 = false;
				}
				else{
					if(abs(re[i]-re[i+1]) < k)
						ok2 = false;
					if(abs(re[i]-re[i-1]) < k)
						ok2 = false;
				}
				if(j == 1){
					if(abs(re[j]-re[j+1]) < k)
					ok2 = false;
				}
				else if(j == n){
					if(abs(re[j]-re[j-1]) < k)
						ok2 = false;
				}
				else{
					if(abs(re[j]-re[j+1]) < k)
						ok2 = false;
					if(abs(re[j]-re[j-1]) < k)
						ok2 = false;
				}	

			}
			else{
				if(i == 1){
					if(abs(re[i]-re[i+1]) < k)
					ok2 = false;
				}
				else if(i == n){
					if(abs(re[i]-re[i-1]) < k)
						ok2 = false;
				}
				else{
					if(abs(re[i]-re[i+1]) < k)
						ok2 = false;
					if(abs(re[i]-re[i-1]) < k)
						ok2 = false;
				}	
			}
			if(ok2){
				//for(int i = 1; i <= n; i++){
				//	cout << re[i] << " ";
				//}
				//cout << endl << "on ok" << endl;
				break;
			}
				
			else{
				swap(re[j], re[i]);
				//for(int i = 1; i <= n; i++){
				//	cout << re[i] << " ";
				//}
				//cout << endl << "ei ollut ok" << endl;
			}
		}

	}
	
	re[0] = 99999999999LL;
	re[n+1] = 999999999999LL;
	for(int i = 1; i <= n; i++){
		if(abs(re[i]-re[i+1]) < k || abs(re[i]-re[i-1]) < k){
			cout << "QAQ" << endl;
			return 0;
		}
	}
	for(int i = 1; i <= n; i++){
		cout << re[i] << " ";
	}
	cout << endl;
	return 0;
}