結果

問題 No.1981 [Cherry 4th Tune N] アルゴリズムが破滅する例
ユーザー 沙耶花
提出日時 2022-06-17 21:41:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 3,967 ms
コンパイル使用メモリ 250,308 KB
最終ジャッジ日時 2025-01-29 21:37:55
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001



int main(){
	
	int N,K;
	cin>>N>>K;
	
	if((N+1)/2 > K){
		cout<<-1<<endl;
		return 0;
	}
	
	vector<int> a,b;
	
	for(int i=N;i>=1;i--){
		if(i==K){
			a.push_back(i);
			b.push_back(i);
			K--;
		}
		else{
			a.push_back(i);
			b.push_back(i-1);
			a.push_back(i);
			b.push_back(i);
			a.push_back(i-1);
			b.push_back(i-1);
			K--;
			i--;
			
		}
	}
	
	cout<<a.size()<<endl;
	rep(i,a.size()){
		cout<<a[i]<<' '<<b[i]<<endl;
	}
	
	
    return 0;
}
0