Submission #3882676


Source Code Expand

#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 100055;
const int MM = 1000000007;

vector<t3> G;

int main()
{
	int L, M = 1;
	scanf("%d", &L); L--;
	int n = 1;
	for(; (1<<n)-1 <= L; n++); n--;
	for(int i = 1; i <= n; i++){
		G.emplace_back(i, i+1, 0);
		G.emplace_back(i, i+1, 1<<i-1);
	}
	L -= (1<<n)-1; M += (1<<n) - 1;
	for(int i = n; i >= 0; i--){
		if(L >= (1<<i)){
			G.emplace_back(i+1, n+1, M);
			L -= 1<<i;
			M += 1<<i;
		}
	}
	printf("%d %d\n", n+1, G.size());
	for(t3 e : G){
		int a, b, c;
		tie(a, b, c) = e;
		printf("%d %d %d\n", a, b, c);
	}
}

Submission Info

Submission Time
Task D - All Your Paths are Different Lengths
User zigui
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1817 Byte
Status AC
Exec Time 1 ms
Memory 256 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:77:33: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘std::vector<std::tuple<int, int, int> >::size_type {aka long unsigned int}’ [-Wformat=]
  printf("%d %d\n", n+1, G.size());
                                 ^
./Main.cpp:62:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &L); L--;
                 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 2
AC × 22
Set Name Test Cases
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
Case Name Status Exec Time Memory
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