답안 #938401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
938401 2024-03-05T05:53:33 Z aaron_dcoder Shift (POI11_prz) C++17
0 / 100
72 ms 26568 KB
#define NDEBUG

#ifdef NDEBUG
#define dbg(TXTMSG) if constexpr (false) cerr << "lol"
#define dbgv(VARN) ((void)0)
#define dbgfor(COND) if constexpr (false) for (COND)

#else
#define _GLIBCXX_DEBUG 1
#define _GLIBCXX_DEBUG_PEDANTIC 1
#pragma GCC optimize("trapv")
#define dbg(TXTMSG) cerr << "\n" << TXTMSG
#define dbgv(VARN) cerr << "\n" << #VARN << " = "<< VARN << ", line: " << __LINE__ << "\n"
#define dbgfor(COND) for (COND)

#endif

#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using pll = pair<ll,ll>;
#define e0 first
#define e1 second
constexpr ll INFTY = 2e18;

ll N;


ll find_remove(ll to_rem, deque<ll>& find_in, deque<ll>& temp)
{
	swap(find_in,temp);
	find_in.resize(temp.size()-1);
	ll i;
	for (i = 0; temp[i]!=to_rem; ++i)
	{
		find_in[i] = temp[i];	
	}
	for (ll j = i; j < ll(find_in.size()); ++j)
	{
		find_in[j] = temp[j+1];
	}
	return i;
}

int main()
{
	cin >> N;

	vector<ll> P(N);
	for (ll i = 0; i < N; ++i)
	{
		cin >> P[i];
	}

	vector<pair<ll,char>> outp;

	deque<ll> remain(P.cbegin(),P.cend());
	deque<ll> temp;
	ll curr=1;

	while (remain.size()>2)
	{
		ll i = find_remove(curr, remain, temp);
		outp.push_back({-i,'a'});

		for (; i > 1; i-=2)
		{
			outp.push_back({2,'a'}); 
			outp.push_back({1,'b'}); 
		}
		if (i==1)
		{
			outp.push_back({1,'a'});
			outp.push_back({2,'b'});
			swap(remain[0],remain[1]);
			i--;
		}
		assert(i==0);
		outp.push_back({-1,'a'});
		curr++;
	}

	if (remain[0]==N-1)
	{
		outp.push_back({-2,'a'});
	}
	else 
	{
		assert(remain[0]==N);
		dbgv("g");

		if (N%2==1)
		{
			cout << "NIE DA SIE";
			return 0;
		}
		for (ll i = 0; i < (N/2)-1; ++i)
		{
			outp.push_back({2,'a'}); 
			outp.push_back({1,'b'});
		}
	}



	stringstream stroutp;
	ll osize = 0;
	pair<ll,char> currcmd={0,'z'};
	for (pair<ll,char> cmd : outp)
	{
		dbgv(cmd.e0 << cmd.e1);
		if (cmd.e1==currcmd.e1) currcmd.e0+=cmd.e0;
		else
		{
			if (currcmd.e0!=0){
				osize+=1;
				stroutp << ((2*N+currcmd.e0)%N) << currcmd.e1 << " ";
			}
			currcmd=cmd;
		}
	}
	cout << osize << "\n";
	cout << stroutp.str();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Expected integer, but "NIE" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Liczby nie zostaly posortowane
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Liczby nie zostaly posortowane
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 728 KB Liczby nie zostaly posortowane
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2000 KB Liczby nie zostaly posortowane
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 17348 KB Liczby nie zostaly posortowane
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 60 ms 23976 KB Liczby nie zostaly posortowane
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 72 ms 26568 KB Litery stowarzyszone z liczbami musza wystepowac naprzemiennie
2 Halted 0 ms 0 KB -