Submission #63300420


Source Code Expand

#ifndef ATCODER // AtCoder 環境でない場合はデバッグモードを有効にする. コンパイルにすごく時間がかかる!
#define _GLIBCXX_DEBUG // out of rangeを検出してくれる。#include<bits/stdc++.h>の前に記述する必要あり
#endif
#include<bits/stdc++.h>
using namespace std;
struct IOSetup {
    IOSetup() {
        // 実行が高速化するコード
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        // 小数点以下10桁まで(四捨五入)
        cout << fixed << setprecision(10);
    }
} iosetup;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, b, a) for (int i = b; i > a; i--)
#define rep3(i, a, b, d) for (int i = a; i < b; i+=d)
#define rrep3(i, b, a, d) for (int i = b; i > a; i-=d)
#define between(x, a, b) (((a) <= (x)) && ((x) < (b)))

// Template function to print various container types
template<typename Container>
void print(const Container& a) {
    cout << "{";
    bool first = true;
    for (const auto& i : a) {
        if (!first) {
            cout << ",";
        }
        cout << i;
        first = false;
    }
    cout << "}" << endl;
}


// Template function to print 2D vector
template<typename T>
void printvec2d(const vector<vector<T>>& a) {
    size_t rows = a.size();
    for (size_t i = 0; i < rows; ++i) {
        print(a[i]);
    }
}

// Template function to print 3D vector
template<typename T>
void printvec3d(const vector<vector<vector<T>>>& a) {
    size_t depth = a.size();
    for (size_t i = 0; i < depth; ++i) {
        printvec2d(a[i]);
        cout << endl;
    }
}

int main() {
    int n, q;
    cin >> n >> q;

    vector<int> hato_house(n);
    vector<int> house_realhouse(n);
    rep(i, n) hato_house[i] = i;
    vector<int> house_hato(n);
    rep(i, n) house_hato[i] = i;
    rep(i, n) house_realhouse[i] = i;
    vector<int> ans;
    rep(i, q) {
        int t, a, b;
        cin >> t;
        if (t == 1) {
            cin >> a >> b;
            a--, b--;
            int now_hato = a;
            int next_house = b;
            hato_house[now_hato] = house_hato[b];
        }
        if (t == 2) {
            cin >> a >> b;
            a--, b--;
            int now_house = house_hato[a], next_house = house_hato[b];
            house_hato[a] = next_house;
            house_hato[b] = now_house;
            house_realhouse[now_house] = b;
            house_realhouse[next_house] = a;
        }
        if (t == 3) {
            cin >> a;
            a--;
            int now_house = hato_house[a];
            ans.push_back(house_realhouse[now_house]);
        }
    }
    for (auto& i : ans) {
        cout << i + 1 << endl;
    }
}

Submission Info

Submission Time
Task D - Pigeon Swap
User kazuki00
Language C++ 23 (gcc 12.2)
Score 350
Code Size 2824 Byte
Status AC
Exec Time 343 ms
Memory 17036 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:75:17: warning: unused variable ‘next_house’ [-Wunused-variable]
   75 |             int next_house = b;
      |                 ^~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 31
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3620 KiB
00_sample_01.txt AC 1 ms 3392 KiB
00_sample_02.txt AC 1 ms 3400 KiB
01_random_03.txt AC 181 ms 15484 KiB
01_random_04.txt AC 179 ms 15416 KiB
01_random_05.txt AC 187 ms 15356 KiB
01_random_06.txt AC 178 ms 15352 KiB
01_random_07.txt AC 10 ms 10764 KiB
01_random_08.txt AC 96 ms 11060 KiB
01_random_09.txt AC 48 ms 15012 KiB
01_random_10.txt AC 96 ms 15096 KiB
01_random_11.txt AC 170 ms 15472 KiB
01_random_12.txt AC 41 ms 14668 KiB
01_random_13.txt AC 266 ms 15840 KiB
01_random_14.txt AC 138 ms 15384 KiB
01_random_15.txt AC 40 ms 14816 KiB
01_random_16.txt AC 317 ms 17036 KiB
01_random_17.txt AC 257 ms 15824 KiB
01_random_18.txt AC 47 ms 15008 KiB
01_random_19.txt AC 140 ms 15432 KiB
01_random_20.txt AC 81 ms 15088 KiB
01_random_21.txt AC 42 ms 14612 KiB
01_random_22.txt AC 250 ms 15820 KiB
01_random_23.txt AC 285 ms 15824 KiB
01_random_24.txt AC 217 ms 15896 KiB
01_random_25.txt AC 327 ms 16948 KiB
01_random_26.txt AC 317 ms 15816 KiB
01_random_27.txt AC 343 ms 16848 KiB
01_random_28.txt AC 194 ms 15392 KiB
01_random_29.txt AC 341 ms 16868 KiB
01_random_30.txt AC 157 ms 4148 KiB