結果

問題 No.429 CupShuffle
ユーザー vjudge1
提出日時 2025-08-27 20:13:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 1,704 ms
コンパイル使用メモリ 194,872 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-27 20:13:44
合計ジャッジ時間 2,986 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     freopen("cup.in","r",stdin); freopen("cup.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:8:41: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     freopen("cup.in","r",stdin); freopen("cup.out","w",stdout);
      |                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:27:28: warning: ‘ans2’ may be used uninitialized [-Wmaybe-uninitialized]
   27 |     cout<<ans1<<' '<<ans2<<'\n';
      |                            ^~~~
main.cpp:20:14: note: ‘ans2’ was declared here
   20 |     int ans1,ans2,flg=true;
      |              ^~~~
main.cpp:27:17: warning: ‘ans1’ may be used uninitialized [-Wmaybe-uninitialized]
   27 |     cout<<ans1<<' '<<ans2<<'\n';
      |                 ^~~
main.cpp:20:9: note: ‘ans1’ was declared here
   20 |     int ans1,ans2,flg=true;
      |         ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
struct change {int x,y;} c[maxn];
int n,k,x,a[maxn],b[maxn];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    freopen("cup.in","r",stdin); freopen("cup.out","w",stdout);
    cin>>n>>k>>x;
    for(int i=1;i<=k;i++) {
        if(i==x) {char aa,bb;cin>>aa>>bb;}
        else cin>>c[i].x>>c[i].y;
    } 
    for(int i=1;i<=n;i++) {
        cin>>b[i];
        a[i]=i;
    }
    for(int i=1;i<x;i++) swap(a[c[i].x],a[c[i].y]);
    for(int i=k;i>x;i--) swap(b[c[i].x],b[c[i].y]);
    int ans1,ans2,flg=true;
    for(int i=1;i<=n;i++) {
        if(a[i]!=b[i]) {
            if(flg) {flg=false,ans1=i;}
            else {ans2=i;break;}
        }
    }
    cout<<ans1<<' '<<ans2<<'\n';
    return 0;
}
0