結果
| 問題 |
No.429 CupShuffle
|
| コンテスト | |
| ユーザー |
tkmst201
|
| 提出日時 | 2017-05-05 23:55:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 1,131 bytes |
| コンパイル時間 | 1,888 ms |
| コンパイル使用メモリ | 164,092 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 09:28:09 |
| 合計ジャッジ時間 | 3,208 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:35:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf("%d %d", a + i, b + i);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:39:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | REP(i, N) scanf("%d", c + i);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;
int N, K, X;
int a[112345], b[112345];
int c[112345], revc[112345];
int main() {
cin >> N >> K >> X;
X--;
REP(i, K) {
if (i == X) {
string s;
cin >> s >> s;
}
else {
scanf("%d %d", a + i, b + i);
a[i]--; b[i]--;
}
}
REP(i, N) scanf("%d", c + i);
for (int i = K - 1; i > X; i--) swap(c[a[i]], c[b[i]]);
REP(i, N) revc[i] = i + 1;
REP(i, X) swap(revc[a[i]], revc[b[i]]);
vector<int> ans;
REP(i, N) if (c[i] != revc[i]) ans.push_back(i + 1);
sort(ALL(ans));
printf("%d %d\n", ans[0], ans[1]);
return 0;
}
tkmst201