結果

問題 No.429 CupShuffle
ユーザー vjudge1
提出日時 2025-08-24 20:28:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 1,809 ms
コンパイル使用メモリ 194,868 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-24 20:28:05
合計ジャッジ時間 3,074 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%lld%lld%lld",&n,&k,&x);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:14:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 else scanf("%lld%lld",&a[i],&b[i]);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:17:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |         for(int i=1;i<=n;i++)scanf("%lld",&q[i]);
      |                              ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k,x,a[123456],b[123456],p[123456],q[123456],s,t;
signed main(){
//	freopen("cup.in","r",stdin);
//	freopen("cup.out","w",stdout);
	scanf("%lld%lld%lld",&n,&k,&x);
	for(int i=1;i<=k;i++){
		if(i==x){
			char ch1,ch2;
			cin>>ch1>>ch2;
		}
		else scanf("%lld%lld",&a[i],&b[i]);
	}
	for(int i=1;i<=n;i++)p[i]=i;
	for(int i=1;i<=n;i++)scanf("%lld",&q[i]);
	for(int i=1;i<x;i++){
		int tmp=p[a[i]];
		p[a[i]]=p[b[i]];
		p[b[i]]=tmp;
	}
	for(int i=k;i>x;i--){
		int tmp=q[a[i]];
		q[a[i]]=q[b[i]];
		q[b[i]]=tmp;
	}
	for(int i=1;i<=n;i++){
		if(p[i]!=q[i]){
			if(s==0)s=i;
			else t=i;
		}
	}
	printf("%lld %lld\n",s,t);
	return 0;
}
0