結果
問題 | No.2719 Equal Inner Products in Permutation |
ユーザー |
![]() |
提出日時 | 2024-07-11 01:54:25 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 1,894 bytes |
コンパイル時間 | 2,603 ms |
コンパイル使用メモリ | 208,824 KB |
実行使用メモリ | 6,512 KB |
最終ジャッジ日時 | 2024-07-11 01:54:34 |
合計ジャッジ時間 | 8,501 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }#define all(x) (x).begin(),(x).end()#define fi first#define se second#define mp make_pair#define si(x) int(x.size())const int mod=998244353,MAX=300005,INF=15<<26;int main(){std::ifstream in("text.txt");std::cin.rdbuf(in.rdbuf());cin.tie(0);ios::sync_with_stdio(false);vector<vector<int>> def={{2,4,9,11},{5,8,6,7},{1,3,10,12}};int N;cin>>N;vector<vector<int>> ans(3);if(N==1) cout<<-1<<endl;else if(N%4==0){for(int q=0;q<N/4;q++){for(int i=0;i<3;i++){for(int x:def[i]){ans[i].push_back(x+q*12);}}}}else if(N%4==1){ans[0]={1,4,6,13,15};ans[1]={2,8,9,10,11};ans[2]={3,5,7,12,14};for(int q=0;q<N/4-1;q++){for(int i=0;i<3;i++){for(int x:def[i]){ans[i].push_back(x+q*12+15);}}}}else if(N%4==2){ans[0]={5,3};ans[1]={4,2};ans[2]={6,1};for(int q=0;q<N/4;q++){for(int i=0;i<3;i++){for(int x:def[i]){ans[i].push_back(x+q*12+6);}}}}else if(N%4==3){ans[0]={1,2,8};ans[1]={3,6,9};ans[2]={7,5,4};for(int q=0;q<N/4;q++){for(int i=0;i<3;i++){for(int x:def[i]){ans[i].push_back(x+q*12+9);}}}}for(int i=0;i<3;i++){for(int x:ans[i]) cout<<x<<" ";}cout<<"\n";}