結果
| 問題 |
No.1523 +/- Tree
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-26 00:54:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 655 bytes |
| コンパイル時間 | 842 ms |
| コンパイル使用メモリ | 69,276 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-26 00:54:29 |
| 合計ジャッジ時間 | 3,402 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 44 |
コンパイルメッセージ
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;
| ^
ソースコード
#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<<" "<<v<<" "<<w<<"\n";
}
}
}