結果

問題 No.1837 Same but Different
ユーザー milanis48663220milanis48663220
提出日時 2022-02-11 22:28:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,377 bytes
コンパイル時間 1,237 ms
コンパイル使用メモリ 121,636 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 04:11:58
合計ジャッジ時間 4,878 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 3 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,380 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-1; i++){
            a.push_back(3*i);
            b.push_back(1+3*i);
        }
        a.push_back(4*n);
        b.push_back(3*n+1);
    }else if(n%3 == 1){
        int x = 0;
        for(int i = 0; i < n-1; i++){
            if(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 x = 0;
        for(int i = 0; i < n-2; i++){
            while(x == 0 || x == 1 || 3*x == n+1 || 3*x == 2*n-4){
                x++;
            }
            a.push_back(x*3);
            b.push_back(x*3+1);
            x++;
        }
        a.push_back(2*n-4);
        b.push_back(0);

        a.push_back(3);
        b.push_back(n+1);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    print_vector(a);
    print_vector(b);
    // debug_value(accumulate(a.begin(), a.end(), 0));
    // debug_value(accumulate(b.begin(), b.end(), 0));
}
0