結果

問題 No.429 CupShuffle
ユーザー ebicochinealebicochineal
提出日時 2016-10-23 02:24:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,052 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 76,176 KB
実行使用メモリ 5,028 KB
最終ジャッジ日時 2023-08-15 11:11:02
合計ジャッジ時間 3,098 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 8 ms
4,376 KB
testcase_11 AC 73 ms
4,972 KB
testcase_12 AC 70 ms
4,656 KB
testcase_13 AC 79 ms
5,028 KB
testcase_14 AC 73 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:23: warning: ‘ans[0]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     cout << ans[0] << " " << ans[1] << endl;
                       ^~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
typedef long long int LLI;
typedef unsigned long long int ULLI;
using namespace std;

int main() {
    int n, k, x;
    vector<int> s;
    cin >> n >> k >> x;
    for (int i = 0; i < n; ++i) { s.push_back(i + 1); }
    for (int i = 0; i < x -1; ++i) {
        int a, b; cin >> a >> b;
        swap(s[a - 1], s[b - 1]);
    }
    string _; cin >> _ >> _;
    vector<pair<int, int>> p;
    for (int i = 0; i < k - x; ++i) {
        int a, b; cin >> a >> b;
        pair<int, int> c(a, b);
        p.push_back(c);
    }
    vector<int> e;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        e.push_back(a);
    }
    reverse(ALL(p));
    for (auto i : p) { swap(e[i.first - 1], e[i.second - 1]); }
    int ans[2], c = 0;
    for (int i = 0; i < n; ++i) { if (s[i] != e[i]) { ans[c++] = i + 1;} }
    cout << ans[0] << " " << ans[1] << endl;
    return 0;
}
0