Submission #18983556


Source Code Expand

Copy
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
//#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}

int main(){
	string f = "FESTIVAL";
	ll n; cin >> n;
	for(int i=2;;i++){
		ll pre = 7 * i;
		ll m = n;
		vector<ll>num;
		rep(j, 7){
			num.pb(m%i);
			pre += m % i;
			m /= i;
		}
		num.pb(m);
		pre += m;
		
		if(pre <= 4990){
			int mx = -1;
			rep(i, num.size()) if(num[i] > 0) chmax(mx, i);
			bool bad = 0;
			for(int i=0;i<mx;i++) if(num[i] == 0) bad = 1;
			if(bad) continue;
			string ans = "";
			for(int j=0;j<mx;j++){
				rep(k, i) ans.pb(f[j]);
			}
			for(int j=mx;j>=0;j--){
				rep(k, num[j]-1) ans.pb(f[j]);
			}
			for(int j=0;j<=7;j++) ans.pb(f[j]);
			cout << ans << endl;
			return 0;
		}
	}
}

Submission Info

Submission Time
Task G - FESTIVAL
User IH19980412
Language C++ (GCC 9.2.1)
Score 1000
Code Size 2042 Byte
Status AC
Exec Time 12 ms
Memory 3652 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:19:31: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   19 | #define rep(i,x) for(int i=0;i<x;i++)
......
   80 |    rep(i, num.size()) if(num[i] > 0) chmax(mx, i);
      |        ~~~~~~~~~~~~~           
./Main.cpp:80:4: note: in expansion of macro ‘rep’
   80 |    rep(i, num.size()) if(num[i] > 0) chmax(mx, i);
      |    ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 2
AC × 56
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 12 ms 3604 KB
001.txt AC 2 ms 3568 KB
002.txt AC 2 ms 3500 KB
003.txt AC 6 ms 3492 KB
004.txt AC 2 ms 3440 KB
005.txt AC 3 ms 3504 KB
006.txt AC 2 ms 3564 KB
007.txt AC 2 ms 3568 KB
008.txt AC 3 ms 3564 KB
009.txt AC 2 ms 3504 KB
010.txt AC 2 ms 3560 KB
011.txt AC 2 ms 3448 KB
012.txt AC 2 ms 3628 KB
013.txt AC 2 ms 3628 KB
014.txt AC 2 ms 3608 KB
015.txt AC 2 ms 3452 KB
016.txt AC 2 ms 3564 KB
017.txt AC 2 ms 3612 KB
018.txt AC 2 ms 3512 KB
019.txt AC 3 ms 3616 KB
020.txt AC 2 ms 3624 KB
021.txt AC 2 ms 3572 KB
022.txt AC 3 ms 3560 KB
023.txt AC 2 ms 3500 KB
024.txt AC 2 ms 3556 KB
025.txt AC 2 ms 3616 KB
026.txt AC 2 ms 3580 KB
027.txt AC 2 ms 3616 KB
028.txt AC 3 ms 3552 KB
029.txt AC 2 ms 3496 KB
030.txt AC 2 ms 3552 KB
031.txt AC 2 ms 3548 KB
032.txt AC 3 ms 3616 KB
033.txt AC 2 ms 3624 KB
034.txt AC 2 ms 3572 KB
035.txt AC 2 ms 3628 KB
036.txt AC 3 ms 3500 KB
037.txt AC 2 ms 3572 KB
038.txt AC 2 ms 3580 KB
039.txt AC 2 ms 3616 KB
040.txt AC 3 ms 3616 KB
041.txt AC 2 ms 3512 KB
042.txt AC 2 ms 3452 KB
043.txt AC 2 ms 3500 KB
044.txt AC 2 ms 3652 KB
045.txt AC 2 ms 3516 KB
046.txt AC 2 ms 3652 KB
047.txt AC 1 ms 3616 KB
048.txt AC 2 ms 3576 KB
049.txt AC 8 ms 3612 KB
050.txt AC 2 ms 3612 KB
051.txt AC 1 ms 3456 KB
052.txt AC 2 ms 3616 KB
053.txt AC 2 ms 3508 KB
example0.txt AC 2 ms 3500 KB
example1.txt AC 3 ms 3504 KB