結果
| 問題 |
No.2929 Miracle Branch
|
| コンテスト | |
| ユーザー |
yurina256
|
| 提出日時 | 2024-10-12 17:10:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 3,342 bytes |
| コンパイル時間 | 3,735 ms |
| コンパイル使用メモリ | 232,352 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-10-12 17:11:11 |
| 合計ジャッジ時間 | 10,853 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 TLE * 1 -- * 17 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define length size()
#define __STDCPP_FLOAT128_T__
#define Real1024 float128_t
#define int long long
#define ll long long
#define ALL(v) (v).begin(), (v).end()
constexpr ll inf = 1001001001001001001ll;
constexpr ll mod = /* 1000000007*/ 998244353;
constexpr double pi = 3.141592653589793;
//小数出力
//cout << setprecision(12);
//max
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
//min
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//print
void print() { cout << '\n'; }
template<typename T>
void print(const T &t) { cout << t << '\n'; }
template<typename Head, typename... Tail>
void print(const Head &head, const Tail &... tail) {
cout << head << ' ';
print(tail...);
}
//join
template<typename T> string join(vector<T> &vec ,const string &sp){
int si = vec.length;
if(si==0){
return "";
}else{
stringstream ss;
rep(i,si-1){
ss << vec[i] << sp;
}
ss << vec[si - 1];
return ss.str();
}
}
bool in_range(int l,int x,int r){//閉区間
return (l <= x ) && (x <= r);
}
int div_ceil(int x,int y){
return (x+y-1)/y;
}
int blood(char x,char y){
if(x == 'O' && y == 'O') return 3;
if((x == 'A' && y == 'B') || (x == 'B' && y == 'A')) return 2;
if(x == 'A' || y == 'A') return 0;
return 1;
}
//Template End
vector<pair<int,int>> p_fact(int N) {
vector<pair<int,int>> res;
for (int a = 2; a * a <= N; ++a) {
if (N % a != 0) continue;
int ex = 0; // 指数
// 割れる限り割り続ける
while (N % a == 0) {
++ex;
N /= a;
}
if(a > 200000){
vector<pair<int,int>> e;
return e;
}
// その結果を push
res.push_back({a, ex});
}
// 最後に残った数について
if (N != 1) res.push_back({N, 1});
return res;
}
void one(){
cout << 2 << endl;
cout << 1 << " " << 2 << endl;
cout << "b g" << endl;
}
signed main(void){
int x;
cin >> x;
if(x == 1){
one();
return 0;
}
auto f = p_fact(x);
if(f.size() == 0){
cout << -1 << endl;
return 0;
}
int b = 0;
int g = 0;
int kkkk = f.size();
rep(i,kkkk){
if(f[i].first == 2){
b += (f[i].second/2)+f[i].second%2;
g += f[i].first*f[i].second;
//cout << b << " " <<g << endl;
int tmp = (f[i].second/2);
f[i].second-=tmp*2;
f.push_back({4,tmp});
}else{
b += f[i].second;
g += f[i].first*f[i].second;
}
}
if(b+g > 200000){
cout << -1 << endl;
return 0;
}
cout << b+g << endl;
int b_cnt = 1;
int g_cnt = b+1;
int edcnt = 0;
rep(i,f.size()){
rep(j,f[i].second){
rep(k,f[i].first){
cout << b_cnt << " " << g_cnt << endl;
g_cnt++;
edcnt++;
}
b_cnt++;
if(b_cnt != b+1){
cout << b_cnt-1 << " " << b_cnt << endl;
edcnt++;
}
}
}
if(edcnt != b+g-1) return -1;
rep(i,b+g-1){
if(i < b) cout << "b ";
else cout << "g ";
}
cout << "g" << endl;
}
yurina256