Submission #100308

# Submission time Handle Problem Language Result Execution time Memory
100308 2019-03-10T11:00:01 Z claudy Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
286 ms 60024 KB
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;
int gcd(int a, int b)
{
    if(b) return gcd(b,a%b);
    return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

stack<int>s;
int n,k,a[1 << 20];
vector<int>vec[1 << 20];

int32_t main(){_
    //freopen("in","r",stdin);
	cin >> n >> k;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
	}
	s.push(29);
	s.push(29);
	for(int i = 1;i <= n;i++)
	{
		/*if(i == 5)
		{
			while(sz(s))
			{
				cout << s.top() << ' ';
				s.pop();
			}
			return 0;
		}*/
		int x = s.top();
		if(a[i] == x)
		{
			s.pop();
			continue;
		}
		else if(a[i] < x)
		{
			s.pop();
			for(int j = x - 1;j >= a[i];j--)
			{
				s.push(j);
			}
		}
		else
		{
			while(s.top() < a[i])
			{
				vec[i].pb(s.top());
				k--;
				s.pop();
			}
			int x = s.top();
			if(a[i] == x)
			{
				s.pop();
				continue;
			}
			else if(a[i] < x)
			{
				s.pop();
				for(int i = x - 1;i >= a[i];i--)
				{
					s.push(i);
				}
			}
		}
	}
	for(int i = 1;i <= n;i++)
	{
		for(auto it : vec[i])
		{
			if(k && it)
			{
				k--;
				cout << it - 1 << ' ' << it - 1 << ' ';
			}
			else cout << it << ' ';
		}
		cout << a[i] << ' ';
	}
	while(sz(s))
	{
		auto it = s.top();
		if(k && it)
			{
				k--;
				cout << it - 1 << ' ' << it - 1 << ' ';
			}
			else cout << it << ' ';
		s.pop();
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 177 ms 33144 KB Expected EOF
2 Incorrect 180 ms 32988 KB Expected EOF
3 Incorrect 172 ms 32976 KB Expected EOF
4 Incorrect 200 ms 33048 KB Expected EOF
5 Incorrect 166 ms 32988 KB Expected EOF
6 Incorrect 200 ms 33016 KB Expected EOF
# Verdict Execution time Memory Grader output
1 Incorrect 286 ms 33016 KB Expected EOF
2 Runtime error 157 ms 60024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 143 ms 59896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Incorrect 182 ms 33164 KB Unexpected end of file - int32 expected
5 Incorrect 163 ms 33068 KB Unexpected end of file - int32 expected
6 Incorrect 200 ms 33016 KB Unexpected end of file - int32 expected
7 Incorrect 168 ms 33016 KB Unexpected end of file - int32 expected
8 Incorrect 178 ms 33276 KB Expected EOF
9 Incorrect 198 ms 35396 KB Expected EOF
10 Incorrect 117 ms 30456 KB Unexpected end of file - int32 expected
11 Incorrect 160 ms 33016 KB Unexpected end of file - int32 expected
12 Incorrect 27 ms 24960 KB Unexpected end of file - int32 expected
13 Incorrect 28 ms 24960 KB Unexpected end of file - int32 expected
14 Incorrect 27 ms 24960 KB Unexpected end of file - int32 expected