結果

問題 No.1523 +/- Tree
ユーザー kotatsugame
提出日時 2025-01-26 00:53:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 659 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 68,160 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-26 00:53:39
合計ジャッジ時間 6,363 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 14 WA * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:25: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   31 |                 for(auto[e,w]:E)
      |                         ^
main.cpp:33:29: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   33 |                         auto[u,v]=e;
      |                             ^

ソースコード

diff #

#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N,K;
	cin>>N>>K;
	vector<pair<pair<int,int>,int> >E;
	if(K==1);
	else if(K==2)
	{
		if(N%2==1);
		else
		{
			for(int i=2;i<=N;i++)E.push_back(make_pair(make_pair(i-1,i),i%2==0?N-1:-N));
		}
	}
	else if(K+2<=N)
	{
		for(int i=2;i<=K;i++)E.push_back(make_pair(make_pair(i-1,i),i==K?-3:0));
		for(int i=K+1;i<=N;i++)E.push_back(make_pair(make_pair(K,i),2));
	}
	else if(K==N-1);
	if(E.empty())cout<<"No\n";
	else
	{
		cout<<"Yes\n";
		for(auto[e,w]:E)
		{
			auto[u,v]=e;
			cout<<u+1<<" "<<v+1<<" "<<w<<"\n";
		}
	}
}
0