結果
問題 | No.1061 素敵な数列 |
ユーザー | Enjapma_kyopro |
提出日時 | 2020-05-16 15:21:24 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 6,307 bytes |
コンパイル時間 | 1,824 ms |
コンパイル使用メモリ | 175,240 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-02 11:47:07 |
合計ジャッジ時間 | 5,788 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,824 KB |
testcase_03 | AC | 1 ms
6,816 KB |
testcase_04 | AC | 1 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | AC | 1 ms
6,820 KB |
testcase_07 | AC | 1 ms
6,820 KB |
testcase_08 | RE | - |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 2 ms
6,816 KB |
testcase_11 | AC | 2 ms
6,816 KB |
testcase_12 | AC | 2 ms
6,820 KB |
testcase_13 | AC | 2 ms
6,820 KB |
testcase_14 | AC | 1 ms
6,816 KB |
testcase_15 | AC | 1 ms
6,820 KB |
testcase_16 | AC | 2 ms
6,816 KB |
testcase_17 | AC | 2 ms
6,820 KB |
testcase_18 | AC | 2 ms
6,820 KB |
testcase_19 | AC | 7 ms
6,820 KB |
testcase_20 | AC | 5 ms
6,816 KB |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 17 ms
6,820 KB |
testcase_24 | AC | 16 ms
6,820 KB |
testcase_25 | AC | 16 ms
6,816 KB |
testcase_26 | AC | 5 ms
6,816 KB |
testcase_27 | AC | 11 ms
6,816 KB |
testcase_28 | RE | - |
testcase_29 | AC | 16 ms
6,816 KB |
testcase_30 | AC | 19 ms
6,816 KB |
testcase_31 | AC | 11 ms
6,816 KB |
testcase_32 | AC | 21 ms
6,820 KB |
testcase_33 | AC | 4 ms
6,820 KB |
testcase_34 | RE | - |
testcase_35 | AC | 7 ms
6,820 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){ return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;} ll mygcd(ll a, ll b){ if(b > a)swap(a, b); if(b == 0 || a == b){ return a; }else{ return mygcd(b, a % b); } } bool multicase = false; ll n,m,num,a,b,c,d,e,h,q; ll w, k; ll x[300006], y[100], z[100]; bool ok = false; bool flag = false; vector<ll> v1 = {2,2,1,1,2,1,0,0,0}; vector<ll> v2 = {3,3,2,2,1,3,2,1,0,0,0,1}; vector<ll> v3 = {4,3,3,2,2,1,3,2,1,4,1,0,0,0,4}; vector<ll> v4 = {1,-1,1,1,0,0,0}; vector<ll> v5 = {2,-1,1,2,2,1,0,0,0,1}; vector<ll> v6 = {3,-1,1,2,3,3,1,2,0,2,0,1,0}; void paint(ll maxi, ll l, ll r, bool hanpa){ if(!hanpa){ if(maxi <= 3){ // 例外処理 if(maxi == 1){ assert(false); }else if(maxi == 2){ for(ll i=0;i<v1.size();i++){ x[l+i] = v1[i]; } }else if(maxi == 3){ for(ll i=0;i<v2.size();i++){ x[l+i] = v2[i]; } }else{ for(ll i=0;i<v3.size();i++){ x[l+i] = v3[i]; } } return; } if(maxi % 2 == 0){ ll idx = l; for(ll i=maxi;i>=maxi/2;i--){ x[idx] = i; x[idx+1] = i; idx += 2; } for(ll i=maxi;i>=maxi/2;i--){ x[idx] = i; idx ++; } paint(maxi/2 - 1, idx, r, false); }else{ ll idx = l; for(ll i=maxi;i>=(maxi+1)/2;i--){ x[idx] = i; x[idx+1] = i; idx += 2; } x[idx] = maxi / 2; idx ++; for(ll i=maxi;i>=(maxi+1)/2;i--){ x[idx] = i; idx ++; } x[idx] = maxi / 2; idx ++; x[idx+1] = maxi / 2; paint(maxi/2-1, idx, r, true); } }else{ ll idx = l; if(maxi <= 3){ // 例外処理 if(maxi == 1){ for(ll i=0;i<v4.size();i++){ if(v4[i] != -1)x[l+i] = v4[i]; } }else if(maxi == 2){ for(ll i=0;i<v5.size();i++){ if(v5[i] != -1)x[l+i] = v5[i]; } }else{ for(ll i=0;i<v6.size();i++){ if(v6[i] != -1)x[l+i] = v6[i]; } } return; }else{ if(maxi % 2 == 1){ x[idx] = maxi; idx += 2; for(ll i=maxi-1;i>=(maxi+1)/2;i--){ x[idx] = i; x[idx+1] = i; idx += 2; } x[idx] = x[idx+1] = maxi; idx += 2; for(ll i=maxi-1;i>=(maxi+1)/2;i--){ x[idx] = i; idx ++; } paint(maxi/2, idx, r, false); }else{ x[idx] = maxi; idx += 2; for(ll i=maxi-1;i>=maxi/2+1;i--){ x[idx] = i; x[idx+1] = i; idx += 2; } x[idx] = maxi/2; idx += 1; x[idx] = x[idx+1] = maxi; idx += 2; for(ll i=maxi-1;i>=maxi/2;i--){ x[idx] = i; idx ++; } x[idx+1] = maxi/2; paint(maxi/2-1, idx, r, true); } } } } void calc(ll n){ if(n == 1){ pe(0);pe(0);p(0); return; }else if(n == 2){ p(-1); return; } paint(n - 1, 1, 3*n, false); reverse(x + 1, x + n * 3 + 1); for(ll i=1;i<n*3;i++){ cout << x[i] << " "; } cout << x[3*n] << endl; } void solve(){ cin >> n; calc(n); 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; }