Task: | Scorpion and frogs |
Sender: | aalto2024a_001 |
Submission time: | 2024-09-04 17:43:28 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.00 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.00 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.00 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | ACCEPTED | 0.00 s | details |
#32 | ACCEPTED | 0.00 s | details |
#33 | ACCEPTED | 0.00 s | details |
#34 | ACCEPTED | 0.00 s | details |
#35 | ACCEPTED | 0.00 s | details |
#36 | ACCEPTED | 0.00 s | details |
#37 | ACCEPTED | 0.00 s | details |
#38 | ACCEPTED | 0.00 s | details |
#39 | ACCEPTED | 0.00 s | details |
#40 | ACCEPTED | 0.00 s | details |
#41 | ACCEPTED | 0.00 s | details |
#42 | ACCEPTED | 0.00 s | details |
#43 | ACCEPTED | 0.00 s | details |
#44 | ACCEPTED | 0.00 s | details |
#45 | ACCEPTED | 0.00 s | details |
#46 | ACCEPTED | 0.00 s | details |
#47 | ACCEPTED | 0.00 s | details |
#48 | ACCEPTED | 0.00 s | details |
#49 | ACCEPTED | 0.00 s | details |
#50 | ACCEPTED | 0.00 s | details |
#51 | ACCEPTED | 0.00 s | details |
#52 | ACCEPTED | 0.00 s | details |
#53 | ACCEPTED | 0.00 s | details |
#54 | ACCEPTED | 0.00 s | details |
#55 | ACCEPTED | 0.01 s | details |
Code
#ifdef ONPC #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> #define char unsigned char #define rep(i, a, b) for(int i=a; i< (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define eb emplace_back #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define LSOne(S) ((S) & -(S)) using namespace std; // mt19937 rnd(239); mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); typedef long long C; typedef complex<C> P; #define X real() #define Y imag() template<class T> istream& operator>> (istream& is, complex<T>& p) { T value; is >> value; p.real(value); is >> value; p.imag(value); return is; } typedef long long ll; typedef long double ld; using pi = pair<ll, ll>; using vi = vector<ll>; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; int popcnt(int x) { return __builtin_popcount(x); } int popcnt(ll x) { return __builtin_popcountll(x); } #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define LB(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define UB(c, x) distance((c).begin(), upper_bound(all(c), (x))) void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifdef DEBUG #define dbg(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl; #else #define dbg(x...) #endif template<typename S, typename T = S> void chmin(S &s, T t) {s = s < t ? s : t;} template<typename S, typename T = S> void chmax(S &s, T t) {s = s > t ? s : t;} const int INF = 1e9; // 10^9 = 1B is < 2^31-1 const ll LLINF = 4e18; // 4*10^18 is < 2^63-1 const double EPS = 1e-9; const ll MOD = 998244353; const int N=1e5+10; ll pref[N]; ll fib[N]; int solve() { int n; std::cin >> n; fib[0]=1; fib[1]=1; for (int i = 2; i <= n+1; i++) { fib[i]=(fib[i-1]+fib[i-2])%MOD; } if(false) { for (int i = 0; i <= n+1; i++) { std::cout << fib[i] << " "; } } std::cout << fib[n+1] << std::endl; //std::cout << fib[n+1] << " " << fib[n] << std::endl; //std::cout << fib[n+1]+fib[n]+1 << std::endl; return 0; pref[0]=1; pref[1]=1; ll res=0; for (int i = 2; i <= n+1; i++) { res+=pref[i-2]; pref[i]=(pref[i-1]+res+1)%MOD; } for (int i = 0; i <= 10; i++) { std::cout << pref[i] << " "; } std::cout << std::endl; std::cout << pref[n+1]+pref[n] << std::endl; //std::cout << res << std::endl; return 0; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); int TET = 1; //cin >> TET; for (int i = 1; i <= TET; i++) { #ifdef ONPC cout << "TEST CASE#" << i << endl; #endif if (solve()) { break; } #ifdef ONPC cout << "__________________________" << endl; #endif } #ifdef ONPC cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl; #endif }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 |
correct output |
---|
2 |
user output |
---|
2 |
Test 2
Verdict: ACCEPTED
input |
---|
2 |
correct output |
---|
3 |
user output |
---|
3 |
Test 3
Verdict: ACCEPTED
input |
---|
3 |
correct output |
---|
5 |
user output |
---|
5 |
Test 4
Verdict: ACCEPTED
input |
---|
4 |
correct output |
---|
8 |
user output |
---|
8 |
Test 5
Verdict: ACCEPTED
input |
---|
5 |
correct output |
---|
13 |
user output |
---|
13 |
Test 6
Verdict: ACCEPTED
input |
---|
6 |
correct output |
---|
21 |
user output |
---|
21 |
Test 7
Verdict: ACCEPTED
input |
---|
7 |
correct output |
---|
34 |
user output |
---|
34 |
Test 8
Verdict: ACCEPTED
input |
---|
8 |
correct output |
---|
55 |
user output |
---|
55 |
Test 9
Verdict: ACCEPTED
input |
---|
9 |
correct output |
---|
89 |
user output |
---|
89 |
Test 10
Verdict: ACCEPTED
input |
---|
10 |
correct output |
---|
144 |
user output |
---|
144 |
Test 11
Verdict: ACCEPTED
input |
---|
11 |
correct output |
---|
233 |
user output |
---|
233 |
Test 12
Verdict: ACCEPTED
input |
---|
12 |
correct output |
---|
377 |
user output |
---|
377 |
Test 13
Verdict: ACCEPTED
input |
---|
13 |
correct output |
---|
610 |
user output |
---|
610 |
Test 14
Verdict: ACCEPTED
input |
---|
14 |
correct output |
---|
987 |
user output |
---|
987 |
Test 15
Verdict: ACCEPTED
input |
---|
15 |
correct output |
---|
1597 |
user output |
---|
1597 |
Test 16
Verdict: ACCEPTED
input |
---|
16 |
correct output |
---|
2584 |
user output |
---|
2584 |
Test 17
Verdict: ACCEPTED
input |
---|
17 |
correct output |
---|
4181 |
user output |
---|
4181 |
Test 18
Verdict: ACCEPTED
input |
---|
18 |
correct output |
---|
6765 |
user output |
---|
6765 |
Test 19
Verdict: ACCEPTED
input |
---|
19 |
correct output |
---|
10946 |
user output |
---|
10946 |
Test 20
Verdict: ACCEPTED
input |
---|
20 |
correct output |
---|
17711 |
user output |
---|
17711 |
Test 21
Verdict: ACCEPTED
input |
---|
30 |
correct output |
---|
2178309 |
user output |
---|
2178309 |
Test 22
Verdict: ACCEPTED
input |
---|
40 |
correct output |
---|
267914296 |
user output |
---|
267914296 |
Test 23
Verdict: ACCEPTED
input |
---|
50 |
correct output |
---|
9216450 |
user output |
---|
9216450 |
Test 24
Verdict: ACCEPTED
input |
---|
60 |
correct output |
---|
865709054 |
user output |
---|
865709054 |
Test 25
Verdict: ACCEPTED
input |
---|
70 |
correct output |
---|
659095774 |
user output |
---|
659095774 |
Test 26
Verdict: ACCEPTED
input |
---|
80 |
correct output |
---|
343522908 |
user output |
---|
343522908 |
Test 27
Verdict: ACCEPTED
input |
---|
90 |
correct output |
---|
666203437 |
user output |
---|
666203437 |
Test 28
Verdict: ACCEPTED
input |
---|
100 |
correct output |
---|
741707250 |
user output |
---|
741707250 |
Test 29
Verdict: ACCEPTED
input |
---|
200 |
correct output |
---|
319277240 |
user output |
---|
319277240 |
Test 30
Verdict: ACCEPTED
input |
---|
300 |
correct output |
---|
12089690 |
user output |
---|
12089690 |
Test 31
Verdict: ACCEPTED
input |
---|
400 |
correct output |
---|
356073916 |
user output |
---|
356073916 |
Test 32
Verdict: ACCEPTED
input |
---|
500 |
correct output |
---|
831535149 |
user output |
---|
831535149 |
Test 33
Verdict: ACCEPTED
input |
---|
600 |
correct output |
---|
627858041 |
user output |
---|
627858041 |
Test 34
Verdict: ACCEPTED
input |
---|
700 |
correct output |
---|
894762479 |
user output |
---|
894762479 |
Test 35
Verdict: ACCEPTED
input |
---|
800 |
correct output |
---|
695610340 |
user output |
---|
695610340 |
Test 36
Verdict: ACCEPTED
input |
---|
900 |
correct output |
---|
120428339 |
user output |
---|
120428339 |
Test 37
Verdict: ACCEPTED
input |
---|
1000 |
correct output |
---|
506723686 |
user output |
---|
506723686 |
Test 38
Verdict: ACCEPTED
input |
---|
2000 |
correct output |
---|
118272245 |
user output |
---|
118272245 |
Test 39
Verdict: ACCEPTED
input |
---|
3000 |
correct output |
---|
50602578 |
user output |
---|
50602578 |
Test 40
Verdict: ACCEPTED
input |
---|
4000 |
correct output |
---|
38687300 |
user output |
---|
38687300 |
Test 41
Verdict: ACCEPTED
input |
---|
5000 |
correct output |
---|
644069919 |
user output |
---|
644069919 |
Test 42
Verdict: ACCEPTED
input |
---|
6000 |
correct output |
---|
905964874 |
user output |
---|
905964874 |
Test 43
Verdict: ACCEPTED
input |
---|
7000 |
correct output |
---|
917351342 |
user output |
---|
917351342 |
Test 44
Verdict: ACCEPTED
input |
---|
8000 |
correct output |
---|
606465604 |
user output |
---|
606465604 |
Test 45
Verdict: ACCEPTED
input |
---|
9000 |
correct output |
---|
676429656 |
user output |
---|
676429656 |
Test 46
Verdict: ACCEPTED
input |
---|
10000 |
correct output |
---|
634342956 |
user output |
---|
634342956 |
Test 47
Verdict: ACCEPTED
input |
---|
20000 |
correct output |
---|
215568895 |
user output |
---|
215568895 |
Test 48
Verdict: ACCEPTED
input |
---|
30000 |
correct output |
---|
54808147 |
user output |
---|
54808147 |
Test 49
Verdict: ACCEPTED
input |
---|
40000 |
correct output |
---|
242971895 |
user output |
---|
242971895 |
Test 50
Verdict: ACCEPTED
input |
---|
50000 |
correct output |
---|
575576968 |
user output |
---|
575576968 |
Test 51
Verdict: ACCEPTED
input |
---|
60000 |
correct output |
---|
923159168 |
user output |
---|
923159168 |
Test 52
Verdict: ACCEPTED
input |
---|
70000 |
correct output |
---|
621454924 |
user output |
---|
621454924 |
Test 53
Verdict: ACCEPTED
input |
---|
80000 |
correct output |
---|
562709198 |
user output |
---|
562709198 |
Test 54
Verdict: ACCEPTED
input |
---|
90000 |
correct output |
---|
389404104 |
user output |
---|
389404104 |
Test 55
Verdict: ACCEPTED
input |
---|
100000 |
correct output |
---|
66655788 |
user output |
---|
66655788 |