結果

問題 No.3091 The Little Match Boy
ユーザー tokitsukaze
提出日時 2025-05-22 20:07:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 432 bytes
コンパイル時間 2,287 ms
コンパイル使用メモリ 197,504 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-05-22 20:07:14
合計ジャッジ時間 5,065 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 62
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::set<std::pair<int, int> >::size_type’ {aka ‘long unsigned int’} [-Wformat=]
   23 |         printf("%d\n",s.size());
      |                 ~^    ~~~~~~~~
      |                  |          |
      |                  int        std::set<std::pair<int, int> >::size_type {aka long unsigned int}
      |                 %ld
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d%d",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |                 scanf("%d",&z);
      |                 ~~~~~^~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3fLL;
const int MAX=2e5+10;
int p[MAX];
int main()
{
	int n,m,i,x,y,z;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++) p[i]=i;
	set<pair<int,int>> s;
	for(i=1;i<=m;i++)
	{
		scanf("%d",&z);
		x=p[z];
		y=p[z+1];
		if(x>y) swap(x,y);
		s.insert({x,y});
		swap(p[z],p[z+1]);
	}
	printf("%d\n",s.size());
	return 0;
}
0