結果

問題 No.1837 Same but Different
ユーザー milanis48663220milanis48663220
提出日時 2022-02-11 22:51:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 2,876 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 123,284 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 05:15:12
合計ジャッジ時間 3,435 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<int> a, b;
    if(n%3 == 0){
        for(int i = 0; i < n; i++){
            a.push_back(3*i);
            b.push_back(1+3*i);
        }
        for(int i = 0; i < n/3; i++){
            int j = n-i-1;
            a[j] += 3;
        }
    }else if(n%3 == 1){
        int x = 0;
        for(int i = 0; i < n-1; i++){
            while(x == 0 || 3*x == n-1){
                x++;
            }
            a.push_back(x*3);
            b.push_back(x*3+1);
            x++;
        }
        a.push_back(n-1);
        b.push_back(0);
    }else{
        int m = n-2;
        for(int i = 0; i < m; i++){
            a.push_back(3*i);
            b.push_back(1+3*i);
        }
        for(int i = 0; i < m/3+1; i++){
            int j = m-i-1;
            a[j] += 3;
        }

        for(int i = 0; i < m; i++){
            a[i] += 45;
            b[i] += 45;
        }

        a.push_back(3);
        b.push_back(0);

        a.push_back(9);
        b.push_back(15);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    print_vector(a);
    print_vector(b);
    // for(int i = 0; i < n; i++){
    //     for(int j = 0; j < n; j++){
    //         for(int k = 0; k < n; k++){
    //             for(int l = 0; l < n; l++){
    //                 if(a[i]+a[j] == b[k]+b[l]){
    //                     cout << i << ' ' << j << ' ' << k << ' ' << l << endl;
    //                 }
    //             }
    //         }
    //     }
    // }
    // debug_value(accumulate(a.begin(), a.end(), 0));
    // debug_value(accumulate(b.begin(), b.end(), 0));
}
0