結果
問題 | No.2929 Miracle Branch |
ユーザー | shihaka(C_plplplpl) |
提出日時 | 2024-10-12 16:42:27 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,187 bytes |
コンパイル時間 | 2,986 ms |
コンパイル使用メモリ | 184,792 KB |
実行使用メモリ | 8,916 KB |
最終ジャッジ日時 | 2024-10-12 16:42:42 |
合計ジャッジ時間 | 12,098 ms |
ジャッジサーバーID (参考情報) |
judge / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 4 ms
6,816 KB |
testcase_19 | AC | 5 ms
6,816 KB |
testcase_20 | AC | 6 ms
6,816 KB |
testcase_21 | AC | 13 ms
6,820 KB |
testcase_22 | WA | - |
testcase_23 | AC | 23 ms
6,820 KB |
testcase_24 | AC | 80 ms
6,816 KB |
testcase_25 | WA | - |
testcase_26 | AC | 3 ms
6,816 KB |
testcase_27 | AC | 3 ms
6,820 KB |
testcase_28 | AC | 4 ms
6,816 KB |
testcase_29 | AC | 3 ms
6,820 KB |
testcase_30 | AC | 3 ms
6,816 KB |
testcase_31 | AC | 4 ms
6,820 KB |
testcase_32 | AC | 4 ms
6,820 KB |
testcase_33 | AC | 3 ms
6,816 KB |
testcase_34 | AC | 254 ms
7,768 KB |
testcase_35 | AC | 303 ms
8,276 KB |
testcase_36 | AC | 3 ms
6,816 KB |
testcase_37 | AC | 262 ms
8,016 KB |
testcase_38 | AC | 261 ms
7,896 KB |
testcase_39 | AC | 269 ms
8,020 KB |
testcase_40 | AC | 274 ms
8,280 KB |
testcase_41 | AC | 295 ms
7,892 KB |
testcase_42 | AC | 258 ms
8,916 KB |
testcase_43 | AC | 259 ms
8,660 KB |
testcase_44 | AC | 275 ms
8,660 KB |
testcase_45 | AC | 2 ms
6,816 KB |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <tuple> #include <cstring> #include <map> #include <set> #include <stack> #include <queue> #include <random> #include <bitset> #include <cassert> #include <atcoder/all> using namespace std; using namespace atcoder; #define overload4(a,b,c,d,name,...) name #define overload3(a,b,c,name,...) name #define rep1(i,n) for(ll i=0;i<(n);++i) #define rep2(i,a,b) for(ll i=(a);i<(b);++i) #define rep3(i,a,b,c) for(ll i=(a);i<(b);i+=(c)) #define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__) #define rrep1(i,n) for(ll i=(n)-1;i>=0;i--) #define rrep2(i,a,b) for(ll i=(b)-1;i>=(a);--i) #define rrep3(i,a,b,c) for(ll i=(b)-1;i>=(a);i-=(c)) #define rrep(...) overload4(__VA_ARGS__,rrep3,rrep2,rrep1)(__VA_ARGS__) #define ALL1(i) begin(i),end(i) #define ALL2(i,a) begin(i),begin(i)+a #define ALL3(i,a,b) begin(i)+a,begin(i)+b #define ALL(...) overload3(__VA_ARGS__,ALL3,ALL2,ALL1)(__VA_ARGS__) #define sz(a) ((ll)a.size()) #define lb(v, x) distance((v).begin(), lower_bound(ALL(v), (x))) #define lbg(v, x) distance((v).begin(), lower_bound(ALL(v), (x), greater{})) #define ub(v, x) distance((v).begin(), upper_bound(ALL(v), (x))) #define ubg(v, x) distance((v).begin(), upper_bound(ALL(v), (x), greater{})) #define SORT(v) sort(ALL(v)) #define RSORT(v) sort(rbegin(v),rend(v)) #define REV(v) reverse(ALL(v)) using ll = long long; using ull = unsigned long long; using P = pair<ll,ll>; using vb = vector<bool>; using vvb = vector<vb>; using vc = vector<char>; using vvc = vector<vc>; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vvvvi = vector<vvvi>; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>; using vvvvl = vector<vvvl>; using vd = vector<double>; using vvd = vector<vd>; using vp = vector<P>; using vvp = vector<vp>; using vs = vector<string>; using vvs = vector<vs>; constexpr ll LINF=2e18; constexpr ll INF=1001001001; constexpr int dx[8]={-1,0,1,0,-1,1,1,-1}; constexpr int dy[8]={0,1,0,-1,1,1,-1,-1}; template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {return ((a < b) ? (a = b, true) : (false));} template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {return ((a > b) ? (a = b, true) : (false));} template<typename T1, typename T2, typename T3> inline bool inRange(const T1 &x, const T2 &l, const T3 &r) {return l <= x & x < r;} constexpr ll div_floor(ll x, ll y) {assert(y != 0); return (x - ((x%y+y)%y)) / y;} constexpr ll div_ceil(ll x, ll y) {assert(y != 0); return (x + ((y-x%y)%y)) / y;} using mint = modint998244353; using vm = vector<mint>; using vvm = vector<vm>; using vvvm = vector<vvm>; using vvvvm = vector<vvvm>; int main() { ll x; cin >> x; ll ox = x; if(x == 1) { cout << 2 << endl; cout << "1 2" << endl; cout << "b g" << endl; return 0; } vl cnt; ll sum = 0; for(ll i = 2; i <= 200000 && i*i <= x; i++) { while(x % i == 0) { cnt.push_back(i); x /= i; sum += i+1; if(sum > 200000) { break; } } } if(x > 1) { cnt.push_back(x); sum += x+1; } if(sum > ox+1) { if(ox+1 > 200000) { cout << -1 << endl; return 0; } //cout << " " << sum << endl; cout << ox+1 << endl; rep(i,ox) { cout << 1 << " " << i+2 << endl; } cout << "b "; rep(i,ox) cout << "g "; cout << endl; return 0; } if(sum > 200000) { cout << -1 << endl; return 0; } vp ans; vc col; rep(i,sz(cnt)-1) { ans.push_back({i+1, i+2}); col.push_back('b'); } col.push_back('b'); ll p = sz(cnt)+1; rep(i,sz(cnt)) { rep(j,cnt[i]) { ans.push_back({i+1, p}); p++; col.push_back('g'); } } cout << sz(col) << endl; rep(i,sz(ans)) { cout << ans[i].first << " " << ans[i].second << endl; } rep(i,sz(col)) { cout << col[i] << " "; } cout << endl; return 0; }