提出 #4410435
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
using VS = vector<string>; using LL = long long;
using VI = vector<int>; using VVI = vector<VI>;
using PII = pair<int, int>; using PLL = pair<LL, LL>;
using VL = vector<LL>; using VVL = vector<VL>;
#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3")
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x)
#endif
const int INF = 1e9; const LL LINF = 1e16;
const LL MOD = 1000000007; const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 }; int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
/* ----- 2019/02/28 Problem: ABC 108 D / Link: http://abc108.contest.atcoder.jp/tasks/abc108_d ----- */
/* ------問題------
-----問題ここまで----- */
/* -----解説等-----
----解説ここまで---- */
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
LL N; cin >> N;
LL Mxidx = 1;
int idxcnt = 0;
while (Mxidx * 2 <= N)Mxidx *= 2, idxcnt++;
DD(de(N, Mxidx, idxcnt));
N--;
// idxcnt分はつくる
int ansN = idxcnt + 1;
using tp = tuple<int, int, int>;
vector<tp>ans;
{
FOR(i, 0, idxcnt) {
ans.push_back(tp(i + 1, i + 2, 1 << i));
ans.push_back(tp(i + 1, i + 2, 0));
}
}
LL sum = 0;
FOR(i, 0, idxcnt) {
sum += 1 << i;
}
DD(de(sum, N));
FOR(i, sum + 1, N + 1) {
DD(de(i));
int cur = i;
int addsum = 0;
FOR(j, 0, idxcnt) {
int add = 1 << j;
if (cur + add <= N) {
cur += add;
addsum += add;
}
else {
ans.push_back(tp(j + 1, idxcnt + 1, i));
i += addsum;
break;
}
}
}
cout << ansN << " " << SZ(ans) << endl;
for (auto it : ans) {
int a, b, c; tie(a, b, c) = it;
cout << a << " " << b << " " << c << endl;
}
return 0;
}
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
700 / 700 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
s1.txt, s2.txt |
| All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, s1.txt, s2.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 01.txt |
AC |
1 ms |
256 KiB |
| 02.txt |
AC |
1 ms |
256 KiB |
| 03.txt |
AC |
1 ms |
256 KiB |
| 04.txt |
AC |
1 ms |
256 KiB |
| 05.txt |
AC |
1 ms |
256 KiB |
| 06.txt |
AC |
1 ms |
256 KiB |
| 07.txt |
AC |
1 ms |
256 KiB |
| 08.txt |
AC |
1 ms |
256 KiB |
| 09.txt |
AC |
1 ms |
256 KiB |
| 10.txt |
AC |
1 ms |
256 KiB |
| 11.txt |
AC |
1 ms |
256 KiB |
| 12.txt |
AC |
1 ms |
256 KiB |
| 13.txt |
AC |
1 ms |
256 KiB |
| 14.txt |
AC |
1 ms |
256 KiB |
| 15.txt |
AC |
1 ms |
256 KiB |
| 16.txt |
AC |
1 ms |
256 KiB |
| 17.txt |
AC |
1 ms |
256 KiB |
| 18.txt |
AC |
1 ms |
256 KiB |
| 19.txt |
AC |
1 ms |
256 KiB |
| 20.txt |
AC |
1 ms |
256 KiB |
| s1.txt |
AC |
1 ms |
256 KiB |
| s2.txt |
AC |
1 ms |
256 KiB |