QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#172930 | #7183. Password | ucup-team1469# | AC ✓ | 4ms | 7068kb | C++17 | 13.4kb | 2023-09-09 21:16:39 | 2023-09-09 21:16:39 |
Judging History
answer
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
#endif
using namespace std;
using ll = long long;
using ull = unsigned long long int;
using i128 = __int128_t;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vc<T>>;
template <typename T> using vvvc = vector<vvc<T>>;
using vi = vc<int>;
using vl = vc<ll>;
using vpi = vc<pii>;
using vpl = vc<pll>;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
#define overload5(a, b, c, d, e, name, ...) name
#define overload4(a, b, c, d, name, ...) name
#define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf)
#define REP1(i, n) for(ll i = 0; i < (n); ++i)
#define REP2(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf)
#define per1(i, n) for(ll i = (n)-1; i >= 0; --i)
#define per2(i, a, b) for(ll i = (a)-1; i >= b; --i)
#define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c))
#define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__)
#define fore0(a) rep(a.size())
#define fore1(i, a) for(auto &&i : a)
#define fore2(a, b, v) for(auto &&[a, b] : v)
#define fore3(a, b, c, v) for(auto &&[a, b, c] : v)
#define fore4(a, b, c, d, v) for(auto &&[a, b, c, d] : v)
#define fore(...) overload5(__VA_ARGS__, fore4, fore3, fore2, fore1, fore0)(__VA_ARGS__)
#define perm(v) for(bool permrepflag = true; (permrepflag ? exchange(permrepflag, false) : next_permutation(all(v)));)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define drop(s) cout << #s << endl, exit(0)
#define si(c) (int)(c).size()
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{}))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{}))
#define rng(v, l, r) v.begin() + (l), v.begin() + (r)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define REV(v) reverse(all(v))
#define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end())
template <typename T = ll, typename S> T SUM(const S &v) { return accumulate(all(v), T(0)); }
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define INT(...) \
int __VA_ARGS__; \
IN(__VA_ARGS__)
#define INTd(...) \
int __VA_ARGS__; \
IN2(__VA_ARGS__)
#define LL(...) \
ll __VA_ARGS__; \
IN(__VA_ARGS__)
#define LLd(...) \
ll __VA_ARGS__; \
IN2(__VA_ARGS__)
#define STR(...) \
string __VA_ARGS__; \
IN(__VA_ARGS__)
#define CHR(...) \
char __VA_ARGS__; \
IN(__VA_ARGS__)
#define LD(...) \
ld __VA_ARGS__; \
IN(__VA_ARGS__)
#define VEC(type, name, size) \
vector<type> name(size); \
IN(name)
#define VECd(type, name, size) \
vector<type> name(size); \
IN2(name)
#define VEC2(type, name1, name2, size) \
vector<type> name1(size), name2(size); \
for(int i = 0; i < size; i++) IN(name1[i], name2[i])
#define VEC2d(type, name1, name2, size) \
vector<type> name1(size), name2(size); \
for(int i = 0; i < size; i++) IN2(name1[i], name2[i])
#define VEC3(type, name1, name2, name3, size) \
vector<type> name1(size), name2(size), name3(size); \
for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i])
#define VEC3d(type, name1, name2, name3, size) \
vector<type> name1(size), name2(size), name3(size); \
for(int i = 0; i < size; i++) IN2(name1[i], name2[i], name3[i])
#define VEC4(type, name1, name2, name3, name4, size) \
vector<type> name1(size), name2(size), name3(size), name4(size); \
for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i], name4[i]);
#define VEC4d(type, name1, name2, name3, name4, size) \
vector<type> name1(size), name2(size), name3(size), name4(size); \
for(int i = 0; i < size; i++) IN2(name1[i], name2[i], name3[i], name4[i]);
#define VV(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
IN(name)
#define VVd(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
IN2(name)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(ld &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &);
template <class T> void scan(vector<T> &a) {
for(auto &i : a) scan(i);
}
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
void IN2() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
scan(head);
IN(tail...);
}
template <class Head, class... Tail> void IN2(Head &head, Tail &...tail) {
scan(head);
--head;
IN2(tail...);
}
template<class T> void prt_(T a){ cout<<a; }
template<class T,class U> void prt_(pair<T,U> a){ cout<<"{"<<a.fi<<", "<<a.se<<"}"; }
void prt_(ld a){ printf("%.15Lf",a); }
template<class T> void prt(vc<T> a){
for(size_t i=0;i<a.size();++i){
prt_(a[i]);
cout<<" \n"[i==a.size()-1];
}
}
template<class T> void prt(vvc<T> a){
for(auto& v:a){
for(size_t i=0;i<v.size();++i){
prt_(v[i]);
cout<<" \n"[i==v.size()-1];
}
}
}
template<class T> void prt(T a){ prt_(a),cout<<"\n"; }
template<class T,class... Args> void prt(T a,Args... args){ prt_(a),cout<<" ",prt(args...); }
template<class Head,class... Tail> struct multi_dim_vector{ using type=vc<typename multi_dim_vector<Tail...>::type>; };
template<class T> struct multi_dim_vector<T>{ using type=T; };
template<class T,class Arg> vc<T> mvec(int n,Arg&& arg){ return vc<T>(n,arg); }
template<class T,class... Args> class multi_dim_vector<Args...,T>::type mvec(int n,Args&&... args){
return typename multi_dim_vector<Args...,T>::type(n,mvec<T>(args...));
}
template<class T> T REVed(T a){
reverse(a.begin(),a.end());
return a;
}
template<class T> T SORTed(T a){
sort(a.begin(),a.end());
return a;
}
template<class T> T RSORTed(T a){
sort(a.rbegin(),a.rend());
return a;
}
vi iota(int n){
vi res(n);
iota(res.begin(),res.end(),0);
return res;
}
template <class T> bool chmax(T &a, T b){ return (a < b ? a = b, 1 : 0); }
template <class T> bool chmin(T &a, T b){ return (a > b ? a = b, 1 : 0); }
template<class T> auto runLength(T a) -> vc<pair<typename decltype(a)::value_type,ll>>{
int n=a.size();
vc<pair<typename decltype(a)::value_type,ll>> res;
if(n==0){ return res; }
typename decltype(a)::value_type now=a[0];
ll l=1;
rep(i,1,n){
if(a[i-1]==a[i]){ l++; }
else{
res.pb(now,l);
now=a[i],l=1;
}
}
res.pb(now,l);
return res;
}
template<int mod> struct mymodint{
ll x;
static constexpr ll get_mod(){ return mod; }
ll val(){ return x; }
mymodint(ll x_=0):x((x_%mod+mod)%mod){}
mymodint operator-(){ return (x==0)?0:mod-x; }
mymodint operator+(mymodint rhs){ return mymodint(*this)+=rhs; }
mymodint operator-(mymodint rhs){ return mymodint(*this)-=rhs; }
mymodint operator*(mymodint rhs){ return mymodint(*this)*=rhs; }
mymodint operator/(mymodint rhs){ return mymodint(*this)/=rhs; }
mymodint pow(ll rhs){
mymodint res=1,now=(*this);
while(rhs){
res*=((rhs&1)?now:1),now*=now,rhs>>=1;
}
return res;
}
mymodint& operator+=(mymodint rhs){
x+=rhs.x,x-=((x>=mod)?mod:0);
return (*this);
}
mymodint& operator-=(mymodint rhs){
x-=rhs.x;
x+=((x<0)?mod:0);
return (*this);
}
mymodint& operator*=(mymodint rhs){
x=x*rhs.x%mod;
return (*this);
}
mymodint& operator/=(mymodint rhs){ return (*this)*=rhs.pow(mod-2); }
bool operator==(mymodint rhs){ return x==rhs.x; }
bool operator!=(mymodint rhs){ return x!=rhs.x; }
};
template<int mod> using modint=
#if __has_include(<atcoder/all>)
atcoder::static_modint<mod>;
#else
mymodint<mod>;
#endif
template<int mod> std::ostream& operator<<(std::ostream& os,modint<mod> x){
return os<<(x.val());
}
template<int mod> std::istream& operator>>(std::istream& is,modint<mod>& x){
ll t;
is>>t,x=t;
return is;
}
template<class T> struct cmb{
vc<T> fac,ifac;
cmb(int mx=3000000):fac(mx+1,1),ifac(mx+1,1){
for(int i=1;i<=mx;++i){ fac[i]=fac[i-1]*i; }
ifac[mx]/=fac[mx];
for(int i=mx;i>0;--i){ ifac[i-1]=ifac[i]*i; }
}
T operator()(ll n,ll k){
if(n<0||k<0||n<k){ return 0; }
return fac[n]*ifac[k]*ifac[n-k];
}
T f(ll n){
return n<0?T(0):fac[n];
}
T fi(ll n){
return n<0?T(0):ifac[n];
}
};
int main(){
using fp=modint<998244353>;
INT(n);
//なるべく 0 を優先
vi a(n,-1);
if(n%2==0){ a[n/2-1]=1,a[n/2]=1; }
else{ a[n/2]=1; }
rep(i,n){
if(a[i]!=-1){ continue; }
if(i<=1){ a[i]=0; }
else if(a[i-2]+a[i-1]==0){ a[i]=1; }
else{ a[i]=0; }
}
prt(SUM(a),n);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
input:
1
output:
1 1
result:
ok single line: '1 1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
2
output:
2 2
result:
ok single line: '2 2'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
3
output:
1 3
result:
ok single line: '1 3'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
10
output:
4 10
result:
ok single line: '4 10'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
5
output:
1 5
result:
ok single line: '1 5'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
6
output:
2 6
result:
ok single line: '2 6'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
7
output:
3 7
result:
ok single line: '3 7'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
8
output:
4 8
result:
ok single line: '4 8'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
9
output:
3 9
result:
ok single line: '3 9'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
4
output:
2 4
result:
ok single line: '2 4'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
9484
output:
3162 9484
result:
ok single line: '3162 9484'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
18500
output:
6168 18500
result:
ok single line: '6168 18500'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
52029
output:
17343 52029
result:
ok single line: '17343 52029'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
74707
output:
24903 74707
result:
ok single line: '24903 74707'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
114210
output:
38070 114210
result:
ok single line: '38070 114210'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
124079
output:
41359 124079
result:
ok single line: '41359 124079'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
140227
output:
46743 140227
result:
ok single line: '46743 140227'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
149321
output:
49773 149321
result:
ok single line: '49773 149321'
Test #19:
score: 0
Accepted
time: 1ms
memory: 4056kb
input:
158606
output:
52870 158606
result:
ok single line: '52870 158606'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
178985
output:
59661 178985
result:
ok single line: '59661 178985'
Test #21:
score: 0
Accepted
time: 2ms
memory: 3912kb
input:
203822
output:
67942 203822
result:
ok single line: '67942 203822'
Test #22:
score: 0
Accepted
time: 2ms
memory: 3928kb
input:
211113
output:
70371 211113
result:
ok single line: '70371 211113'
Test #23:
score: 0
Accepted
time: 2ms
memory: 4028kb
input:
211702
output:
70568 211702
result:
ok single line: '70568 211702'
Test #24:
score: 0
Accepted
time: 2ms
memory: 4120kb
input:
239252
output:
79752 239252
result:
ok single line: '79752 239252'
Test #25:
score: 0
Accepted
time: 0ms
memory: 4312kb
input:
251157
output:
83719 251157
result:
ok single line: '83719 251157'
Test #26:
score: 0
Accepted
time: 2ms
memory: 4188kb
input:
268701
output:
89567 268701
result:
ok single line: '89567 268701'
Test #27:
score: 0
Accepted
time: 2ms
memory: 4124kb
input:
292633
output:
97545 292633
result:
ok single line: '97545 292633'
Test #28:
score: 0
Accepted
time: 2ms
memory: 4360kb
input:
355864
output:
118622 355864
result:
ok single line: '118622 355864'
Test #29:
score: 0
Accepted
time: 2ms
memory: 4740kb
input:
385320
output:
128440 385320
result:
ok single line: '128440 385320'
Test #30:
score: 0
Accepted
time: 2ms
memory: 4732kb
input:
414180
output:
138060 414180
result:
ok single line: '138060 414180'
Test #31:
score: 0
Accepted
time: 2ms
memory: 5040kb
input:
447973
output:
149325 447973
result:
ok single line: '149325 447973'
Test #32:
score: 0
Accepted
time: 3ms
memory: 4920kb
input:
462908
output:
154304 462908
result:
ok single line: '154304 462908'
Test #33:
score: 0
Accepted
time: 2ms
memory: 5000kb
input:
473412
output:
157804 473412
result:
ok single line: '157804 473412'
Test #34:
score: 0
Accepted
time: 3ms
memory: 5304kb
input:
511511
output:
170503 511511
result:
ok single line: '170503 511511'
Test #35:
score: 0
Accepted
time: 3ms
memory: 5176kb
input:
539439
output:
179813 539439
result:
ok single line: '179813 539439'
Test #36:
score: 0
Accepted
time: 1ms
memory: 5500kb
input:
586698
output:
195566 586698
result:
ok single line: '195566 586698'
Test #37:
score: 0
Accepted
time: 3ms
memory: 5640kb
input:
673221
output:
224407 673221
result:
ok single line: '224407 673221'
Test #38:
score: 0
Accepted
time: 0ms
memory: 5816kb
input:
683861
output:
227953 683861
result:
ok single line: '227953 683861'
Test #39:
score: 0
Accepted
time: 1ms
memory: 6024kb
input:
711682
output:
237228 711682
result:
ok single line: '237228 711682'
Test #40:
score: 0
Accepted
time: 1ms
memory: 6020kb
input:
727899
output:
242633 727899
result:
ok single line: '242633 727899'
Test #41:
score: 0
Accepted
time: 1ms
memory: 6100kb
input:
738039
output:
246013 738039
result:
ok single line: '246013 738039'
Test #42:
score: 0
Accepted
time: 3ms
memory: 6140kb
input:
754671
output:
251557 754671
result:
ok single line: '251557 754671'
Test #43:
score: 0
Accepted
time: 3ms
memory: 6292kb
input:
815233
output:
271745 815233
result:
ok single line: '271745 815233'
Test #44:
score: 0
Accepted
time: 3ms
memory: 6500kb
input:
843192
output:
281064 843192
result:
ok single line: '281064 843192'
Test #45:
score: 0
Accepted
time: 4ms
memory: 6736kb
input:
898513
output:
299505 898513
result:
ok single line: '299505 898513'
Test #46:
score: 0
Accepted
time: 1ms
memory: 7036kb
input:
955601
output:
318533 955601
result:
ok single line: '318533 955601'
Test #47:
score: 0
Accepted
time: 1ms
memory: 6764kb
input:
967629
output:
322543 967629
result:
ok single line: '322543 967629'
Test #48:
score: 0
Accepted
time: 4ms
memory: 7068kb
input:
990687
output:
330229 990687
result:
ok single line: '330229 990687'
Test #49:
score: 0
Accepted
time: 4ms
memory: 6920kb
input:
999999
output:
333333 999999
result:
ok single line: '333333 999999'
Test #50:
score: 0
Accepted
time: 2ms
memory: 7000kb
input:
1000000
output:
333334 1000000
result:
ok single line: '333334 1000000'
Extra Test:
score: 0
Extra Test Passed