Submission #602320

# Submission time Handle Problem Language Result Execution time Memory
602320 2022-07-22T21:52:33 Z UncoolAnon Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
4 ms 616 KB
#include <bits/stdc++.h> 

#define pii pair<int,int> 
#define F first 
#define S second 
#define mp make_pair 

using namespace std; 
 

signed main(){
	ios_base::sync_with_stdio(0); 
	cin.tie(nullptr); 
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout); 
	#endif 
	int n,k; 
	cin>>n>>k; 
	vector<int> a(n); 
	for(int&x:a) cin>>x; 
	int answer=(1<<30); 
	for(int&x:a) answer-=(1<<x); 
	vector<int> added,ones; 
	for(int i=0;i<30;i++)
		if((1<<i)&answer){
			added.push_back(i); 
		}

	while(added.size()+ones.size()<k){
		if(added.back()==0){
			added.pop_back(); 
			ones.push_back(0); 
		}
		else{
			int tmp=added.back(); 
			added.pop_back(); 
			added.push_back(tmp-1); 
			added.push_back(tmp-1); 
		}
	}
	for(int&x:a) cout << x << " "; 
	for(int&x:added) cout << x << " " ; 
	for(int&x:ones) cout << x << " " ; 
	return 0 ; 
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:30:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |  while(added.size()+ones.size()<k){
      |        ~~~~~~~~~~~~~~~~~~~~~~~~^~
zalmoxis.cpp:15:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   freopen("in.txt","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~
zalmoxis.cpp:16:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   freopen("out.txt","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 596 KB Execution killed with signal 11
2 Runtime error 2 ms 468 KB Execution killed with signal 11
3 Runtime error 2 ms 468 KB Execution killed with signal 11
4 Runtime error 2 ms 596 KB Execution killed with signal 11
5 Runtime error 2 ms 596 KB Execution killed with signal 11
6 Runtime error 2 ms 596 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Runtime error 2 ms 596 KB Execution killed with signal 11
3 Runtime error 3 ms 596 KB Execution killed with signal 11
4 Runtime error 2 ms 596 KB Execution killed with signal 11
5 Runtime error 2 ms 596 KB Execution killed with signal 11
6 Runtime error 2 ms 596 KB Execution killed with signal 11
7 Runtime error 3 ms 516 KB Execution killed with signal 11
8 Runtime error 3 ms 596 KB Execution killed with signal 11
9 Runtime error 2 ms 596 KB Execution killed with signal 11
10 Runtime error 2 ms 596 KB Execution killed with signal 11
11 Runtime error 2 ms 468 KB Execution killed with signal 11
12 Runtime error 4 ms 616 KB Execution killed with signal 11
13 Runtime error 2 ms 596 KB Execution killed with signal 11
14 Runtime error 2 ms 596 KB Execution killed with signal 11