結果
問題 |
No.3287 Golden Ring
|
ユーザー |
|
提出日時 | 2025-10-03 21:33:31 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 3,642 bytes |
コンパイル時間 | 2,781 ms |
コンパイル使用メモリ | 290,980 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-03 21:33:35 |
合計ジャッジ時間 | 3,758 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/dsu> #include <cstdio> #include <iostream> #include <set> #include <vector> #include <algorithm> #include <iomanip> #include <cmath> #include <map> #include <queue> #ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif using namespace std; #define pb push_back #define all(v) v.begin(), v.end() #define sz(v) (int)v.size() //--------------型系---------------- using ll = long long; using ull = unsigned long long; //--------------配列系-------------- using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>; using vs = vector<string>; using vvs = vector<vs>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; using vld = vector<long double>; using vvld = vector<vld>; using P = pair<ll, ll>;using vp = vector<P>; using mpll = map<ll, ll>; //--------------出力---------------- #define YES cout<<"Yes"<<endl #define NO cout<<"No"<<endl #define YN {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}// if(a==b)YN; #define v_cout(v){ll n = size(v);rep(i,n)cout<<v[i]<<endl;}//一次元配列を出力する #define vv_cout(v){ll n = size(v);rep(i,n){rep(j,size(v[i])){cout<<v[i][j]<<' ';}cout<<endl;}}//二次元配列を出力する //関数 //---------------rep系--------------- #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i,n) for(ll i = 1; i <= (n); ++i) #define drep(i,n) for(ll i = (n)-1; i >= 0; --i) #define nfor(i,s,n) for(ll i=s;i<n;i++)//i=s,s+1...n-1 ノーマルfor #define dfor(i,s,n) for(ll i = (s)-1; i>=n;i--)//s-1スタートでnまで落ちる //--------------平均average 分散variance 標準偏差std_dev-------------------- double average(int n, vector<double>& s) { double sum = 0; rep(i, n) { sum += s[i]; } return static_cast<double>(sum) / n; } double variance(int n, vector<double>& s) { double avg = average(n, s); double var = 0.0; rep (i,n) { var += pow(s[i]-avg,2); } return var / n; } double std_dev(int n, vector<double>& s) { double sum = 0; rep(i, n) { sum += s[i]; } double average = static_cast<double>(sum) / n; double variance = 0.0; rep (i,n) { variance += pow(s[i]-average,2); } variance /= n; return sqrt(variance); } //--------------------整数問題系-------------------- ll base(ll a, ll x) {//aをx進数に変換 ll result = 0,power_of_10 = 1; while (a > 0) {result +=(a % x)* power_of_10; a /= x; power_of_10 *= 10;} return result; } ll gcd(ll a, ll b) {//最大公約数,ユークリッドの互除法 if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) {//最小公倍数 return a / gcd(a, b) * b; } ll nc2(ll x) { return x * (x - 1) / 2; }//Combination ll nc3(ll x) { return x * (x - 1) * (x - 2) / 6; }//Combination //---------------------------------------- #define uni(v) sort(all(v));v.erase( unique(all(v)), v.end() );//配列の重複を削除する #define vc_rotate(v) rotate(v.begin(),v.begin()+1,v.end());//先頭の要素を末尾に回す #define vc_reverse(v) reverse(v.begin(),v.end());//配列を反転する #define rsort(v) sort(v.rbegin(),v.rend());//配列を降順にソートする void solve() { } int main() {cin.tie(nullptr);ios::sync_with_stdio(false);cout << fixed << setprecision(10); ll n;cin >> n; vl a(n);rep(i,n) a[i]=i+1; do{ mpll mp; rep(i,n-1) mp[a[i]+a[i+1]]++; mp[a[n-1]+a[0]]++; if (mp.size()==n){ YES; rep(i,n) cout << a[i] << " "; cout << endl; return 0; } } while(next_permutation(all(a))); NO; }