結果

問題 No.1571 All Your Cycles Are Same Lengths
ユーザー どらら
提出日時 2021-06-27 14:12:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,220 bytes
コンパイル時間 3,896 ms
コンパイル使用メモリ 229,144 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 11:33:25
合計ジャッジ時間 4,427 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
//using mint = modint1000000007;
//using mint = modint998244353;
void solve(int N, int T){
if(T%N==0){
int a = T/N;
cout << "Yes" << endl;
rep(i,N){
REP(j,i+1,N){
cout << i+1 << " " << j+1 << " " << a << endl;
}
}
return;
}
if(N > 2){
int x = 2;
int y = N-2;
int a = -1;
int b = -1;
rep(aa,101){
rep(bb,101){
if(x*aa + y*bb == T){
a = aa;
b = bb;
}
}
}
if(a >= 0){
cout << "Yes" << endl;
rep(i,N){
REP(j,i+1,N){
if(i==0) cout << i+1 << " " << j+1 << " " << a << endl;
else cout << i+1 << " " << j+1 << " " << b << endl;
}
}
return;
}
}
cout << "No" << endl;
}
int main(){
int Q;
cin >> Q;
rep(q,Q){
int N, T;
cin >> N >> T;
solve(N, T);
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0