結果

問題 No.3091 The Little Match Boy
ユーザー tokitsukaze
提出日時 2025-05-22 20:04:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 395 bytes
コンパイル時間 2,374 ms
コンパイル使用メモリ 197,304 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2025-05-22 20:04:09
合計ジャッジ時間 6,429 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 51
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20: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=]
   20 |         printf("%d\n",s.size()/2);
      |                 ~^    ~~~~~~~~~~
      |                  |            |
      |                  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",&x);
      |                 ~~~~~^~~~~~~~~

ソースコード

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;
	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",&x);
		s.insert({p[x],p[x+1]});
		swap(p[x],p[x+1]);
	}
	printf("%d\n",s.size()/2);
	return 0;
}
0