Submission #848183


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) | rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxlog = 70;
const int maxn = 100100;

int N, n;
LL a[maxn + 5];

struct data
{
	LL num[maxn + 5];

	data() { memset(num, 0, sizeof num); }
	
	friend data operator+(const data &x, const data &y)
	{
		data ans;
		REP(i, 0, N) ans.num[i] = x.num[i] + y.num[i];
		return ans;
	}

	data &operator+=(const data &x)
	{
		REP(i, 0, N) num[i] += x.num[i];
		return *this;
	}
	
	friend data operator*(const data &x, const LL &y)
	{
		data ans;
		REP(i, 0, N) ans.num[i] = x.num[i] * y;
		return ans;
	}

	data &operator*=(const LL &x)
	{
		REP(i, 0, N) num[i] *= x;
		return *this;
	}

	void print()
	{
		REP(i, 0, N) debug("%lld ", num[i]);
	}

};

int tot = 0;
data val[maxlog + 5];
LL len[maxlog + 5];

vector<LL> all;

inline data calc(int id)
{
	if (!id)
	{
		data ret;
		for (auto u : all) if (u > 0) ++ret.num[u - 1];
		for (int i = N - 2; i >= 0; --i) ret.num[i] += ret.num[i + 1];
		return ret;
	}
	LL cnt = 0;
	for (auto &u : all)
	{
		cnt += u / len[id - 1];
		u %= len[id - 1];
	}
	data ret = val[id - 1] * cnt;
	ret += calc(id - 1);
	return ret;
}

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int qn;
	scanf("%d%d", &N, &qn);
	LL x;
	n = 0;
	a[n++] = N;
	REP(i, 0, qn)
	{
		scanf("%" LLFORMAT "d", &x);
		while (n && a[n - 1] > x) --n; 
		a[n++] = x;
	}
	int lst = 0;
	REP(i, 0, a[0]) val[0].num[i] = 1;
	len[0] = a[0];
	++tot;
	REP(i, 1, n)
	{
		if (!~lst || a[i] >= (a[lst] << 1) || (i == n - 1))
		{
			len[tot] = a[i];
			val[tot] = calc(tot - 1);
			val[tot] += val[tot - 1];
			val[tot] *= a[i] / a[i - 1];
			all.clear();
			all.pb(a[i] % a[i - 1]);
			val[tot] += calc(tot - 1);
			++tot;
			all.clear();
			lst = i;
		}
		else all.pb(a[i] - a[lst]);
	}
	REP(i, 0, N) printf("%" LLFORMAT "d\n", val[tot - 1].num[i]);
	return 0;
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User matthew99
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2647 Byte
Status WA
Exec Time 1496 ms
Memory 110204 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:107:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &qn);
                        ^
./Main.cpp:113:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%" LLFORMAT "d", &x);
                              ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1400
Status
AC × 2
AC × 11
WA × 26
RE × 1
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, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt WA 164 ms 66432 KB
02.txt WA 216 ms 71936 KB
03.txt WA 191 ms 69632 KB
04.txt WA 181 ms 68864 KB
05.txt WA 244 ms 74368 KB
06.txt WA 410 ms 82428 KB
07.txt WA 409 ms 82300 KB
08.txt WA 393 ms 82424 KB
09.txt WA 464 ms 84856 KB
10.txt WA 414 ms 82424 KB
11.txt WA 391 ms 81656 KB
12.txt WA 437 ms 83192 KB
13.txt WA 441 ms 83192 KB
14.txt WA 412 ms 82424 KB
15.txt WA 410 ms 82424 KB
16.txt WA 410 ms 82424 KB
17.txt WA 412 ms 82424 KB
18.txt WA 411 ms 82428 KB
19.txt WA 363 ms 80120 KB
20.txt WA 404 ms 82424 KB
21.txt WA 1496 ms 110204 KB
22.txt WA 592 ms 90108 KB
23.txt WA 865 ms 97788 KB
24.txt RE 309 ms 61312 KB
25.txt WA 875 ms 97664 KB
26.txt WA 1211 ms 104448 KB
27.txt AC 126 ms 59136 KB
28.txt AC 138 ms 63092 KB
29.txt AC 138 ms 63092 KB
30.txt WA 139 ms 63092 KB
31.txt AC 101 ms 61312 KB
32.txt AC 111 ms 59136 KB
33.txt AC 96 ms 58880 KB
34.txt AC 129 ms 63488 KB
35.txt AC 100 ms 61184 KB
36.txt AC 92 ms 62848 KB
s1.txt AC 101 ms 61184 KB
s2.txt AC 102 ms 62080 KB