結果
問題 | No.429 CupShuffle |
ユーザー | FF256grhy |
提出日時 | 2016-10-24 03:34:53 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 1,775 bytes |
コンパイル時間 | 230 ms |
コンパイル使用メモリ | 31,360 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-05-03 05:10:34 |
合計ジャッジ時間 | 1,139 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 0 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 0 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 0 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 3 ms
5,376 KB |
testcase_11 | AC | 32 ms
5,376 KB |
testcase_12 | AC | 31 ms
5,376 KB |
testcase_13 | AC | 32 ms
5,376 KB |
testcase_14 | AC | 32 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d%d%d", &n, &k, &x); x--; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:34:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | if(i != x) { scanf("%d%d", &a[i], &b[i]); a[i]--; b[i]--; } | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:35:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | else { scanf("%*s%*s"); } | ~~~~~^~~~~~~~~~ main.cpp:37:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 37 | inc(i, n) { scanf("%d", &c[i]); } | ~~~~~^~~~~~~~~~~~~ main.cpp:50:15: warning: ‘e’ may be used uninitialized [-Wmaybe-uninitialized] 50 | d[ e[0] ] = 1; | ~~~^ main.cpp:44:13: note: ‘e’ declared here 44 | int e[2], f = 0; | ^ main.cpp:51:15: warning: ‘e’ may be used uninitialized [-Wmaybe-uninitialized] 51 | d[ e[1] ] = 1; | ~~~^ main.cpp:44:13: note: ‘e’ declared here 44 | int e[2], f = 0; | ^
ソースコード
#include <cstdio> #include <cmath> #define incID(i, l, r) for(int i = (l) ; i < (r); i++) #define incII(i, l, r) for(int i = (l) ; i <= (r); i++) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--) #define decII(i, l, r) for(int i = (r) ; i >= (l); i--) #define inc( i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec( i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) typedef long long signed int LL; typedef long long unsigned int LU; template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; } template<typename T> T abs(T x) { return (0 <= x ? x : -x); } template<typename T> T max(T a, T b) { return (b <= a ? a : b); } template<typename T> T min(T a, T b) { return (a <= b ? a : b); } template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } } template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } } template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } // ---- ---- int n, k, x, a[100000], b[100000], c[100000]; int d[100000]; int main() { scanf("%d%d%d", &n, &k, &x); x--; inc(i, k) { if(i != x) { scanf("%d%d", &a[i], &b[i]); a[i]--; b[i]--; } else { scanf("%*s%*s"); } } inc(i, n) { scanf("%d", &c[i]); } inc(i, n) { d[i] = i + 1; } inc(i, k) { if(i != x) { swap(d[ a[i] ], d[ b[i] ]); } } int e[2], f = 0; inc(i, n) { if(d[i] != c[i]) { e[f++] = i; } } inc(i, n) { d[i] = 0; } d[ e[0] ] = 1; d[ e[1] ] = 1; decID(i, x + 1, k) { swap(d[ a[i] ], d[ b[i] ]); } int g[2], h = 0; inc(i, n) { if(d[i] != 0) { g[h++] = i; } } printf("%d %d\n", g[0] + 1, g[1] + 1); return 0; }