Submission #200607

# Submission time Handle Problem Language Result Execution time Memory
200607 2020-02-07T14:51:18 Z mohammad Gondola (IOI14_gondola) C++14
Compilation error
0 ms 0 KB
/*
░░░░██████████████████
░░▄███████▀▀▀▀▀▀███████▄
░▐████▀▒mohammad▒▀██████▄
░███▀▒▒▒▒alaa▒▒▒▒▒▒▀█████
░▐██▒▒▒alwrawrah▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
*/
 
#include<bits/stdc++.h>
#include "gondola.h"
using namespace std;
 
typedef long long ll ;
const ll oo = 4294967296 ;
const double PI = acos(-1) ;
const ll M = 998244353   ;

map<int,int> mp;
vector<pair<int,int>> v;
pair<int, int> p[1000010] ;
int valid(int n, int inputSeq[]){
	return -1 ;
}

// ----------------------

int replacement(int n, int gondolaSeq[], int replacementSeq[]){
	bool b = false ;
	for(int i = 0 ; i < n ; ++i){
		p[i] = {gondolaSeq[i] , i + 1};
		mp[gondolaSeq[i]]++;
		if(mp[gondolaSeq[i]] > 1)return 0;
		if(gondolaSeq[i] <= n){
			b = 1;
			int x = gondolaSeq[i];
			int f = i - 1;
			while(f > -1 && gondolaSeq[f] > n){
				x--;
				if(x == 0) x = n;
				v.push_back({gondolaSeq[f] , x});
				gondolaSeq[f] = x;
				mp[x]++;	
				if(mp[x] > 1) return 0 ;
				f--;
			}
			f = i + 1 ;
			x = gondolaSeq[i];
			while(f < n && gondolaSeq[f] > n){
				x++;
				if(x == n + 1) x = 1;
				v.push_back({gondolaSeq[f] , x});
				gondolaSeq[f] = x;
				mp[x]++;
				if(mp[x] > 1)return 0;
				f++;
			}
			i = f - 1;
		}
	}
	int l = 0 , ls = n + 1;
	if(b){
		for(int i = 1 ; i < n ; ++i)
			if((gondolaSeq[i] == 1 && gondolaSeq[i - 1] != n) || (gondolaSeq[i] != 1 && gondolaSeq[i - 1] + 1 != gondolaSeq[i])) return 0;
		sort(v.begin(), v.end());
		for(auto x : v){
			replacementSeq[l++] = x.second;
			while(ls < x.first)
				replacementSeq[l++] =ls++;
			ls++;
		}
	}else{
		sort(p[i] , p[i] + n);
		for(int i = 0 ; i < n ; ++i){
			replacementSeq[l++] = p[i].second;
			while(ls < p[i].first)
				replacementSeq[l++] =ls++;	
			ls++;
		}
	}
	return l ;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
  return -3;
}

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:83:10: error: 'i' was not declared in this scope
   sort(p[i] , p[i] + n);
          ^