結果
問題 | No.2719 Equal Inner Products in Permutation |
ユーザー | shobonvip |
提出日時 | 2024-04-06 10:36:54 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 2,610 bytes |
コンパイル時間 | 4,245 ms |
コンパイル使用メモリ | 266,364 KB |
実行使用メモリ | 10,036 KB |
最終ジャッジ日時 | 2024-10-01 03:47:22 |
合計ジャッジ時間 | 8,229 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 1 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 1 ms
5,248 KB |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 41 ms
7,552 KB |
testcase_16 | AC | 47 ms
9,744 KB |
testcase_17 | AC | 29 ms
6,836 KB |
testcase_18 | AC | 48 ms
9,896 KB |
testcase_19 | AC | 38 ms
7,324 KB |
testcase_20 | AC | 28 ms
6,716 KB |
testcase_21 | AC | 47 ms
10,036 KB |
testcase_22 | AC | 35 ms
7,076 KB |
testcase_23 | AC | 30 ms
6,936 KB |
testcase_24 | AC | 26 ms
6,672 KB |
testcase_25 | AC | 49 ms
9,984 KB |
testcase_26 | AC | 50 ms
9,988 KB |
testcase_27 | AC | 48 ms
9,860 KB |
testcase_28 | AC | 50 ms
9,856 KB |
testcase_29 | AC | 48 ms
9,988 KB |
testcase_30 | AC | 51 ms
9,868 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } void validation(int n, vector<int> p){ assert(p.size() == 3 * n); vector<int> dar(3 * n); rep(i,0,3 * n){ assert(1 <= p[i] && p[i] <= 3 * n); assert(dar[p[i] - 1] == 0); dar[p[i] - 1] = 1; } ll t = 0; rep(i,0,n){ t += p[i] * p[i+n]; t -= p[i+n] * p[i+2*n]; } assert(t == 0); } int main(){ int n; cin >> n; vector<vector<int>> small = { {-1}, {-1}, {1, 4, 3, 6, 5, 2}, {2, 9, 1, 6, 7, 8, 5, 3, 4}, {7, 10, 2, 8, 1, 3, 11, 9, 6, 12, 4, 5}, }; if (n <= 4){ int m = small[n].size(); //validation(n, small[n]); rep(i,0,m){ cout << small[n][i] << ' '; } cout << '\n'; }else{ vector<int> base; if (n % 3 == 0){ base = small[3]; }else if(n % 3 == 1){ base = small[4]; }else if(n % 3 == 2){ base = small[2]; } vector<int> up; vector<int> middle; vector<int> down; rep(i,0,(int)base.size() / 3){ up.push_back(base[i]); } rep(i,(int)base.size() / 3, (int)base.size() / 3 * 2){ middle.push_back(base[i]); } rep(i,(int)base.size() / 3 * 2, (int)base.size() / 3 * 3){ down.push_back(base[i]); } while((int)up.size() < n){ int k = (int)up.size() * 3; rep(i,0,3){ up.push_back(small[3][i] + k); } rep(i,3,6){ middle.push_back(small[3][i] + k); } rep(i,6,9){ down.push_back(small[3][i] + k); } } vector<int> ans; for (int i: up) ans.push_back(i); for (int i: middle) ans.push_back(i); for (int i: down) ans.push_back(i); int m = ans.size(); //validation(n, ans); rep(i,0,m){ cout << ans[i] << ' '; } cout << '\n'; } }