답안 #227147

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227147 2020-04-26T09:14:05 Z kshitij_sodani Konstrukcija (COCI20_konstrukcija) C++17
15 / 110
5 ms 384 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl "\n"



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	llo k;
	cin>>k;
	if(k==0){

		cout<<3<<" "<<2<<endl;
		cout<<1<<" "<<2<<endl;
		cout<<2<<" "<<3<<endl;
		return 0;
	}
	llo st=0;
	llo prod=1;
	vector<llo> ex;
	vector<vector<llo>> ac;
	ac.pb({1});
	llo ind=2;
	llo pre[60];
	pre[0]=1;
	for(llo i=1;i<60;i++){
		pre[i]=pre[i-1]*2;
	}
//	cout<<pre[54]<<endl;
	for(llo i=54;i>=0;i--){
	//	cout<<(llo)(1<<i)<<endl;

		llo acc=(pre[i]&k);
		if(acc==(llo)0){
			if(st==0){
				continue;
			}
			else{
				ac.pb({ind,ind+1,ind+2});
				ind+=3;
				prod*=-2;
			}
		}
		else{
			if(st==0){
				st=1;

			}
			else{
				//ac.pb({ind,ind+1,ind+2});
				//prod*=2;
				if(prod<0){
					ac.pb({ind,ind+1});
					ind+=2;
					prod*=-1;
				}
				ac.pb({ind,ind+1,ind+2,ind+3});
				ind+=4;
				prod*=-2;
			}
		}
	}
	if(prod==k){
		ac.pb({ind,ind+1});
		ind+=2;
	}
	ac.pb({ind});
	ind+=1;
	vector<pair<llo,llo>> ans;
	for(llo i=1;i<ac.size();i++){
		for(llo j=0;j<min((llo)3,(llo)ac[i].size());j++){
			for(auto k:ac[i-1]){
				ans.pb({k,ac[i][j]});
			}
		}
		if(ac[i].size()==4){
			ans.pb({1,ac[i][3]});
		}
	}
	cout<<ind-1<<" "<<ans.size()<<endl;
	for(auto j:ans){
		cout<<j.a<<" "<<j.b<<endl;
	}





	return 0;
}

Compilation message

konstrukcija.cpp: In function 'int main()':
konstrukcija.cpp:77:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(llo i=1;i<ac.size();i++){
              ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Correct.
2 Correct 5 ms 384 KB Correct.
3 Correct 4 ms 384 KB Correct.
4 Correct 4 ms 384 KB Correct.
5 Correct 4 ms 384 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 384 KB Wrong answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Correct.
2 Correct 5 ms 384 KB Correct.
3 Correct 4 ms 384 KB Correct.
4 Correct 4 ms 384 KB Correct.
5 Correct 4 ms 384 KB Correct.
6 Incorrect 4 ms 384 KB Wrong answer.
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Correct.
2 Correct 5 ms 384 KB Correct.
3 Correct 4 ms 384 KB Correct.
4 Correct 4 ms 384 KB Correct.
5 Correct 4 ms 384 KB Correct.
6 Incorrect 4 ms 384 KB Wrong answer.
7 Halted 0 ms 0 KB -