QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#493777 | #9133. Function with Many Maximums | ucup-team159# | AC ✓ | 24ms | 3688kb | C++23 | 4.7kb | 2024-07-27 12:17:06 | 2024-07-27 12:17:07 |
Judging History
answer
#line 1 "D.cpp"
// #pragma GCC target("avx2,avx512f,avx512vl,avx512bw,avx512dq,avx512cd,avx512vbmi,avx512vbmi2,avx512vpopcntdq,avx512bitalg,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("Ofast")
#line 2 "/home/sigma/comp/library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> bool chmax(T& x, U y){
if(x<y){ x=y; return true; }
return false;
}
template<class T,class U> bool chmin(T& x, U y){
if(y<x){ x=y; return true; }
return false;
}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class T> int lwb(const V<T>& v, const T& a){return lower_bound(all(v),a) - v.begin();}
template<class T>
V<T> Vec(size_t a) {
return V<T>(a);
}
template<class T, class... Ts>
auto Vec(size_t a, Ts... ts) {
return V<decltype(Vec<T>(ts...))>(a, Vec<T>(ts...));
}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
o<<"{";
for(const T& v:vc) o<<v<<",";
o<<"}";
return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
os<<t<<" ~ ";
dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {"; \
for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif
template<class D> D divFloor(D a, D b){
return a / b - (((a ^ b) < 0 && a % b != 0) ? 1 : 0);
}
template<class D> D divCeil(D a, D b) {
return a / b + (((a ^ b) > 0 && a % b != 0) ? 1 : 0);
}
/*
x 0 1 2 3 4 5 6 7 8 9
bsr(x) -1 0 1 1 2 2 2 2 3 3
最上位bit
*/
int bsr(int x){
return x == 0 ? -1 : 31 ^ __builtin_clz(x);
}
int bsr(uint x){
return x == 0 ? -1 : 31 ^ __builtin_clz(x);
}
int bsr(ll x){
return x == 0 ? -1 : 63 ^ __builtin_clzll(x);
}
int bsr(ull x){
return x == 0 ? -1 : 63 ^ __builtin_clzll(x);
}
/*
x 0 1 2 3 4 5 6 7 8 9
bsl(x) -1 0 1 0 2 0 1 0 3 0
最下位bit
*/
int bsl(int x){
if(x==0) return -1;
return __builtin_ctz(x);
}
int bsl(uint x){
if(x==0) return -1;
return __builtin_ctz(x);
}
int bsl(ll x){
if(x==0) return -1;
return __builtin_ctzll(x);
}
int bsl(ull x){
if(x==0) return -1;
return __builtin_ctzll(x);
}
#line 5 "D.cpp"
void TEST(){
// ll n; cin >> n;
ll n = 500000;
ll a0 = 2 * TEN(11);
ll s = 0;
ll p = n;
bool ishappy = true;
cout << n << endl;
int cnt = 0;
ll last_i = -1;
for(ll i=a0;;i++){
auto select = [&](){
// cerr << "select : " << i << endl;
cout << i << " ";
ll ns = s - i*2;
ll np = p-1;
ns += np;
s = ns, p = np;
};
auto happy = [&](){
ll ns = s - i*2;
ll np = p-1;
ns += np;
return ns <= 0 && (ns%np == 0);
};
if(p <= 2){
cerr << "p : too small" << endl; break;
}
if(s == 0){
// should select i
// cerr << "become 0 at : " << i << " num: " << cnt << endl;
select();
cnt++;
if(cnt%1000 == 0) cerr << "become 0 at : " << i << " num: " << cnt << endl;
if(cnt == 100000){
last_i = i;
cerr << "done" << endl; break;
}
// skip to mod合わせられるとこ
ll k = s - 2*(i+1); k %= p-1; if(k < 0) k += p-1;
s += k * p;
i += k;
ishappy = false;
continue;
}
if(s > 0){
cerr << "s : toobig" << endl; break;
}
if(!ishappy && happy()){
// mod をあわせられる
ishappy = true;
select();
i += -s/p; s = 0; // skip to 0
}else{
s += p;
}
}
// cerr << "final cnt = " << cnt << endl;
// cerr << "s: " << s << endl;
// cerr << "p: " << p << endl;
{
ll i = last_i + 1;
rep(j,p) cout << i+j << " ";
cout << endl;
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false); //DON'T USE scanf/printf/puts !!
cout << fixed << setprecision(20);
TEST();
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 24ms
memory: 3648kb
input:
4
output:
500000 200000000000 200000299986 200001600007 200001799875 200003200033 200003299631 200004800078 200005299246 200006400143 200006798731 200008000227 200008298083 200009600330 200009797302 200011200452 200011296388 200012800593 200013295323 200014400754 200014794138 200016000934 200016292820 2000176...
result:
ok n=500000, max_a=555547057855, max_num=100000 >= 4
Test #2:
score: 0
Accepted
time: 21ms
memory: 3688kb
input:
100000
output:
500000 200000000000 200000299986 200001600007 200001799875 200003200033 200003299631 200004800078 200005299246 200006400143 200006798731 200008000227 200008298083 200009600330 200009797302 200011200452 200011296388 200012800593 200013295323 200014400754 200014794138 200016000934 200016292820 2000176...
result:
ok n=500000, max_a=555547057855, max_num=100000 >= 100000
Extra Test:
score: 0
Extra Test Passed