Submission #16877227
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long mx = 1e5+5;
#define inf INT_MAX
#define zero -9e18
#define PI acos(-1.0) // 3.1415926535897932
#define Case(J) printf("Case %lld: %lld\n",++count,J); ///print case
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) (a*(b/__gcd(a,b) ))
#define MP make_pair
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define rev(v) reverse(v.begin(),v.end());
#define srt(v) sort(v.begin(),v.end());
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>());
#define hellyeah exit(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define vmax(V) *max_element(V.begin(),V.end());
#define vmin(V) *min_element(V.begin(),V.end());
#define debug(a) cout<<"*"<<a<<"$"<<endl;
#define debug2(a,b) cout<<"$"<<a<<" "<<b<<"$"<<endl;
#define debug3(a,b,c) cout<<"$"<<a<<" "<<b<<" "<<c<<"$"<<endl;
#define SET(X,D_type) memset(X, D_type, sizeof(X))
#define groot(A) {cout<<A<<endl;return;}
#define vins(V) srt(V)V.resize(unique(V.begin(),V.end())-V.begin());
#define check cout<<"Avengers Assemble"<<endl;
#define lol cout<<endl;
#define meem(X) cout<<(X?"Yes":"No")<<endl;
#define joker(V) for(auto X:V)cout<<X<<" ";cout<<endl;
#define papiya(Mp) for(auto X:Mp)cout<<X.first<<" "<<X.second<<endl;
#define lp(i,a) for(ll i=0; i<a;i++)
#define lp1(i,a,b) for(ll i=a; i<=b;i++)
#define rlp(i,b,a) for(ll i=(b);i>=(a);--i)
#define Mat(mat,N,M) lp(i,N){lp(j,M)cout<<mat[i][j]<<" \n"[j==M-1];}
typedef long long ll;
void Loser(){ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
ll fact(ll N){return (N<=1ll?1ll:N*fact(N-1ll));}
long long ceil(ll A,ll B){if(A%B==0)return A/B;else return (A/B)+1ll;}
long long middle(ll a, ll b, ll c) { if ((a <= b && b <= c) || (c <= b && b <= a)) return b;else if ((b <= a && a <= c) || (c <= a && a <= b))return a;else return c; }
bool ispalindrom(string s) {transform(s.begin(),s.end(),s.begin(),::tolower);return (s[0]==s[s.size()-1]?1:0);}
//sort(v.begin(),v.end(),as_second);
bool as_second(const pair<ll,ll> &a, const pair<ll,ll> &b) {return (a.second < b.second); }//sort the vector pair in assending order according to second element
bool ds_first(const pair<ll,ll> &a, const pair<ll,ll> &b){ return (a.first > b.first);}//sort the vector pair in decending order according to first element
bool ds_second(const pair<ll,ll> &a, const pair<ll,ll> &b) {return a.second>b.second;}//sort the vector pair in decending order according to second element
/*max element in map*/
template<typename KeyType, typename ValueType> //auto max=get_max(x);
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {//std::cout << max.first << "=>" << max.second << std::endl; //set->max:m=*a.rbegin();min:mi=*a.begin();
using pairtype=std::pair<KeyType,ValueType>;
return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
return p1.second < p2.second;//min->p1.second>p2.second
});
}
typedef deque<ll> Dq;
typedef set<ll> St;
typedef map<ll,ll> M;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<pair<ll,ll>> VP;
string str,str1,str2,str3,str4,str5,str6,str7;
char ch,ch1,ch2,ch3;
bool flag,flag1,flag2;
long long a,b,c,d,e,f,g,h,l,i,j,k,m,n,o,p,q,r,s,t,u,v,w,x,y,z,test,cnt,cnt1,cnt2,cnt3,cnt4,sum,sum1,sum2,sum3,ans,ans1,ans2,ans3,ma,ma1,ma2,ma3,mi,mi1,mi2,mi3,temp,temp1,temp2,temp3,temp4;
//long double a,b,c,d,e,f,g,h,l,i,j,k,m,n,o,p,q,r,s,t,u,v,w,x,y,z,cnt,cnt1,cnt2,cnt3,cnt4,sum,sum1,sum2,sum3,ans,ans1,ans2,ans3,ma,ma1,ma2,ma3,mi,mi1,mi2,mi3,temp,temp1,temp2,temp3,temp4;
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
void SectumSempra()
{
cin>>sum>>k;
V v;
lp(i,k)
{
cin>>x>>y;
lp1(j,x,y)v.pb(j);
}
vins(v);
//joker(v)
n=v.size();
vector<ll>dp(sum,0);
dp[0]=1;
for(ll j=1;j<sum;++j)
{
for(ll i=0;i<n;++i)
{
if(j>=v[i])
{
dp[j]=(dp[j]%mod+dp[j-v[i]]%mod)%mod;
dp[j]%=mod;
}
}
}
cout<<dp[sum-1]<<endl;
}
int main()
{
Loser();
test=1;
//cin>>test;
while(test--)
{
SectumSempra();
}
return 0;
}
Submission Info
| Submission Time |
|
| Task |
D - Leaping Tak |
| User |
Perdente |
| Language |
C++ (GCC 9.2.1) |
| Score |
0 |
| Code Size |
4597 Byte |
| Status |
TLE |
| Exec Time |
2205 ms |
| Memory |
6540 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
0 / 400 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
s1.txt, s2.txt, s3.txt, s4.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, s1.txt, s2.txt, s3.txt, s4.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 01.txt |
AC |
6 ms |
3516 KiB |
| 02.txt |
AC |
3 ms |
3568 KiB |
| 03.txt |
AC |
3 ms |
3516 KiB |
| 04.txt |
AC |
3 ms |
3564 KiB |
| 05.txt |
AC |
2 ms |
3584 KiB |
| 06.txt |
AC |
1 ms |
3568 KiB |
| 07.txt |
AC |
8 ms |
3568 KiB |
| 08.txt |
AC |
2 ms |
3496 KiB |
| 09.txt |
AC |
2 ms |
3512 KiB |
| 10.txt |
AC |
2 ms |
3576 KiB |
| 11.txt |
AC |
3 ms |
3584 KiB |
| 12.txt |
TLE |
2205 ms |
6540 KiB |
| 13.txt |
AC |
16 ms |
4784 KiB |
| 14.txt |
AC |
91 ms |
4692 KiB |
| 15.txt |
AC |
71 ms |
4716 KiB |
| 16.txt |
TLE |
2205 ms |
5908 KiB |
| 17.txt |
TLE |
2205 ms |
6436 KiB |
| 18.txt |
TLE |
2205 ms |
6456 KiB |
| 19.txt |
TLE |
2205 ms |
6244 KiB |
| 20.txt |
TLE |
2205 ms |
5772 KiB |
| 21.txt |
AC |
11 ms |
4608 KiB |
| 22.txt |
AC |
7 ms |
4664 KiB |
| 23.txt |
AC |
5 ms |
4640 KiB |
| 24.txt |
AC |
7 ms |
4664 KiB |
| s1.txt |
AC |
3 ms |
3564 KiB |
| s2.txt |
AC |
2 ms |
3512 KiB |
| s3.txt |
AC |
2 ms |
3584 KiB |
| s4.txt |
AC |
2 ms |
3504 KiB |