Submission #847603


Source Code Expand

Copy
/*
*/
#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>  
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-10
#define M_PI 3.141592653589793
#define bs 1000000007;
#define bsize 512

const int N = 233031;

using namespace std;

long long toadd[N];
long long n, Q;
long long q[N];

vector<pair<long long, long long> > queries[N];

vector<pair<long long, long long> > renorm(vector<pair<long long, long long> > v)
{
	vector<pair<long long, long long> > res;
	sort(v.begin(), v.end());
	long long cnt = 0;
	for (int i = 0; i < v.size(); i++)
	{
		if (i>0 && v[i].first != v[i - 1].first)
		{
			res.push_back(make_pair(v[i - 1].first, cnt));
			cnt = 0;
		}
		cnt += v[i].second;
	}
	if (cnt)
		res.push_back(make_pair(v.back().first, cnt));
	return res;
}

int main(){
	//freopen("beavers.in","r",stdin);
	//freopen("beavers.out","w",stdout);
	//freopen("F:/in.txt","r",stdin);
	//freopen("F:/output.txt","w",stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> n >> Q;
	for (int i = 1; i <= Q; i++)
	{
		cin >> q[i];
	}

	queries[Q].push_back(make_pair(q[Q], 1));

	q[0] = 1;

	for (int i = Q; i; --i)
	{
		queries[i] = renorm(queries[i]);
		//cout << queries[i].size() << endl;

/*		for (int j = 0; j < queries[i].size(); j++)
		{
			cout << queries[i][j].first << "%" << queries[i][j].second << endl;
		}
		cout << endl;
		*/
		for (int j = 0; j < queries[i].size(); j++)
		{
			long long ps = queries[i][j].first;
			long long times = queries[i][j].second;
			if (ps >= q[i-1])
			{
				queries[i - 1].push_back(make_pair(q[i - 1], ps / q[i - 1]*times));
			}
			if (ps%q[i - 1])
			{
				queries[i - 1].push_back(make_pair(ps%q[i - 1], times));
			}
		}
	}

	long long ttl = 0;

	for (int j = 0; j < queries[1].size(); j++)
	{
		ttl += queries[1][j].second;
		toadd[queries[1][j].first + 1] += queries[1][j].second;
	}

	//cout << ttl << endl;

	for (int i = 1; i <= n; i++)
	{
		ttl -= toadd[i];
		cout << ttl << "\n";
	}

	cin.get(); cin.get();
	return 0;
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User LeBron
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2558 Byte
Status WA
Exec Time 2137 ms
Memory 347324 KB

Compile Error

./Main.cpp:32:0: warning: "M_PI" redefined
 #define M_PI 3.141592653589793
 ^
In file included from /usr/include/c++/5/cmath:44:0,
                 from /usr/include/c++/5/complex:44,
                 from ./Main.cpp:9:
/usr/include/math.h:372:0: note: this is the location of the previous definition
 # define M_PI  3.14159265358979323846 /* pi */
 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1400
Status
AC × 2
AC × 8
WA × 4
TLE × 18
RE × 8
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 RE 955 ms 32768 KB
02.txt RE 394 ms 32512 KB
03.txt RE 401 ms 33024 KB
04.txt RE 393 ms 32768 KB
05.txt RE 406 ms 35328 KB
06.txt TLE 2137 ms 346812 KB
07.txt TLE 2137 ms 344576 KB
08.txt TLE 2137 ms 341436 KB
09.txt TLE 2137 ms 346940 KB
10.txt TLE 2137 ms 341948 KB
11.txt TLE 2137 ms 346172 KB
12.txt TLE 2133 ms 345404 KB
13.txt TLE 2137 ms 344892 KB
14.txt TLE 2133 ms 339772 KB
15.txt TLE 2137 ms 346172 KB
16.txt TLE 2133 ms 344252 KB
17.txt TLE 2137 ms 339260 KB
18.txt TLE 2137 ms 340096 KB
19.txt TLE 2137 ms 347324 KB
20.txt TLE 2133 ms 338876 KB
21.txt TLE 2128 ms 287488 KB
22.txt TLE 2128 ms 288768 KB
23.txt TLE 2128 ms 289792 KB
24.txt WA 366 ms 58624 KB
25.txt RE 462 ms 45312 KB
26.txt AC 327 ms 50944 KB
27.txt AC 69 ms 9856 KB
28.txt AC 80 ms 9856 KB
29.txt AC 69 ms 9856 KB
30.txt WA 70 ms 9856 KB
31.txt AC 12 ms 5760 KB
32.txt WA 24 ms 5888 KB
33.txt AC 12 ms 5760 KB
34.txt RE 197 ms 5760 KB
35.txt WA 12 ms 5760 KB
36.txt RE 199 ms 5760 KB
s1.txt AC 12 ms 5760 KB
s2.txt AC 12 ms 5760 KB