結果
問題 | No.1061 素敵な数列 |
ユーザー | Enjapma_kyopro |
提出日時 | 2020-05-19 13:03:51 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 5,314 bytes |
コンパイル時間 | 2,066 ms |
コンパイル使用メモリ | 175,880 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-02 11:48:27 |
合計ジャッジ時間 | 5,802 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | RE | - |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
6,824 KB |
testcase_06 | AC | 2 ms
6,820 KB |
testcase_07 | AC | 2 ms
6,824 KB |
testcase_08 | AC | 2 ms
6,820 KB |
testcase_09 | AC | 2 ms
6,820 KB |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | AC | 2 ms
6,820 KB |
testcase_13 | AC | 2 ms
6,816 KB |
testcase_14 | AC | 2 ms
6,820 KB |
testcase_15 | AC | 2 ms
6,820 KB |
testcase_16 | AC | 1 ms
6,824 KB |
testcase_17 | AC | 1 ms
6,816 KB |
testcase_18 | AC | 2 ms
6,824 KB |
testcase_19 | AC | 7 ms
6,820 KB |
testcase_20 | RE | - |
testcase_21 | AC | 12 ms
6,816 KB |
testcase_22 | AC | 21 ms
6,820 KB |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | AC | 5 ms
6,820 KB |
testcase_27 | AC | 10 ms
6,816 KB |
testcase_28 | AC | 11 ms
6,816 KB |
testcase_29 | AC | 15 ms
6,820 KB |
testcase_30 | AC | 17 ms
6,820 KB |
testcase_31 | AC | 10 ms
6,816 KB |
testcase_32 | AC | 22 ms
6,820 KB |
testcase_33 | AC | 5 ms
6,824 KB |
testcase_34 | AC | 7 ms
6,820 KB |
testcase_35 | AC | 6 ms
6,816 KB |
ソースコード
#include <bits/stdc++.h> #include <unistd.h> #include <sys/time.h> #include <stdlib.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef pair<P, ll> T; long long int INF = 2e18; const ll fact_table = 1200008; double Pi = 3.1415926535897932384626; priority_queue <ll> pql; priority_queue <P> pqp; priority_queue <P> bag; //big priority queue priority_queue <ll,vector<ll>,greater<ll> > pqls; priority_queue <P,vector<P>,greater<P> > pqps; //small priority queue //top pop ll dx[8]={1,0,-1,0,1,1,-1,-1}; ll dy[8]={0,1,0,-1,1,-1,-1,1}; char dir[] = "DRUL"; //↓,→,↑,← #define endl "\n" #ifdef ENJAPMA #undef endl #endif #define p(x) cout<<x<<endl; #define el cout<<endl; #define pe(x) cout<<x<<" "; #define ps(x) cout<<fixed<<setprecision(25)<<x<<endl; #define pu(x) cout<<(x); #define pb push_back #define lb lower_bound #define ub upper_bound #define CLEAR(a) a = decltype(a)(); #define pc(x) cout << x << ","; const ll mod = 998244353ll; // const ll mod = 1000000007ll; ll mypow(ll number1,ll number2, ll mod){ if(number2 == 0){ return 1ll; }else{ ll number3 = mypow(number1,number2 / 2, mod); number3 *= number3; number3 %= mod; if(number2%2==1){ number3 *= number1; number3 %= mod; } return number3; } } void YES(bool condition){ if(condition){ p("YES"); }else{ p("NO"); } return; } void Yes(bool condition){ if(condition){ p("Yes"); }else{ p("No"); } return; } /* ll fact[fact_table + 5],rfact[fact_table + 5]; void c3_init(){ fact[0] = rfact[0] = 1; for(ll i=1; i<=fact_table; i++){ fact[i] = (fact[i-1]*i) % mod; } rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod); for(ll i=fact_table; i>=1; i--){ rfact[i-1] = rfact[i] * i; rfact[i-1] %= mod; } return;} ll c3(ll n,ll r){ assert(n >= r); assert(n >= 0); assert(r >= 0); return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;} */ bool multicase = false; ll n,m,num,a,b,c,d,e,q; bool used[200005]; ll k; ll x[300005]; void paintN(ll maxi, ll l, ll r); void paintM(ll maxi, ll l, ll r); void paintN(ll maxi, ll l, ll r){ // pe("N=");p(maxi); if(maxi <= 4){ // 埋め込み if(maxi == 0){ x[l] = x[l+1] = x[l+2] = 0; }else if(maxi == 1){ assert(false); }else if(maxi == 2){ x[l] = x[l+2] = x[l+6] = 2; x[l+1] = x[l+4] = x[l+7] = 0; x[l+3] = x[l+5] = x[l+8] = 1; }else if(maxi == 3){ x[l] = x[l+1] = x[l+5] = 3; x[l+2] = x[l+3] = x[l+6] = 2; x[l+4] = x[l+7] = x[l+11] = 1; x[l+8] = x[l+9] = x[l+10] = 0; }else if(maxi == 4){ x[l] = x[l+9] = x[l+14] = 4; x[l+1] = x[l+2] = x[l+6] = 3; x[l+3] = x[l+4] = x[l+7] = 2; x[l+5] = x[l+8] = x[l+10] = 1; x[l+11] = x[l+12] = x[l+13] = 0; } return; } if(maxi % 2 == 0){ ll idx = l; for(ll i=maxi;i>=maxi/2;i--){ x[idx++] = i; x[idx++] = i; } for(ll i=maxi;i>=maxi/2;i--){ x[idx++] = i; } paintN(maxi/2-1, idx, r); }else{ ll idx = l; ll mini = (maxi + 1) / 2; for(ll i=mini;i<maxi;i++){ x[idx++] = i; } x[idx++] = maxi, x[idx++] = maxi; for(ll i=mini;i<maxi;i++){ x[idx++] = i; x[idx++] = i; } x[idx+1] = maxi; paintM(maxi/2, idx, r); } return; } void paintM(ll maxi, ll l, ll r){ // pe("M=");p(maxi); if(maxi <= 2){ if(maxi == 0){ assert(false); }else if(maxi == 1){ x[l] = x[l+2] = x[l+3] = 1; }else if(maxi == 2){ x[l] = x[l+3] = x[l+6] = 0; x[l+2] = x[l+4] = x[l+7] = 1; x[l+5] = x[l+8] = x[l+9] = 2; } return; } if(maxi % 2 == 0){ ll idx = r - 1; for(ll i=maxi;i>=maxi/2;i--){ x[idx--] = i; x[idx--] = i; } for(ll i=maxi;i>=maxi/2;i--){ x[idx--] = i; } paintM(maxi/2-1, l, idx+1); }else{ vector<ll> v; ll mini = (maxi + 1) / 2; for(ll i=mini;i<maxi;i++){ v.pb(i); } v.pb(maxi); v.pb(maxi); for(ll i=mini;i<maxi;i++){ v.pb(i); v.pb(i); } v.pb(0); v.pb(maxi); reverse(v.begin(), v.end()); for(ll i=l;i<l+v.size();i++){ if(v[i-l] != 0)x[i] = v[i-l]; } paintN(maxi/2, l+v.size(), r); } return; } void solve(){ cin >> n; if(n == 2){ p(-1); return; } paintN(n-1, 0, 3*n); for(ll i=0;i<3*n-1;i++){ cout << x[i] << " "; } cout << x[3*n-1] << endl; return; } int main(){ // init(); ios::sync_with_stdio(false); cin.tie(nullptr); ll q, testcase = 1; if(multicase){ cin >> q; }else{ q = 1; } while(q--){ // pu("Case ");pu("#");pu(testcase);pu(": "); solve(); testcase++; } // solve(); return 0; }