Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- using namespace std;
- using ll = long long;
- using ld = long double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector<int>> &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- int inf = 998244353, ans=0;
- int d;
- vector <int> qn;
- vector <int> ax;
- vector <vector <int> > pnt; //points at the distance = r
- int pl(int msk){
- //cout<<"msk = "<<msk<<"\n";
- int res = 0;
- vector <int> use;
- for (int i = 0; i < d; ++i){
- if (msk & (1 << i)){
- use.push_back(i);
- }
- }
- /*cout<<"use\n";
- cv(use);
- cout<<"pnt.size() = "<<pnt.size()<<"\n";*/
- for (int r = 1; r < pnt[0].size(); ++r){
- int fct = 1;
- //cout<<"r = "<<r<<"\n";
- for (int j = 0; j < use.size();++j){
- //cout<<"r use[j] = "<<r<<' '<<use[j]<<"\n";
- //cout<<"pnt[use[j]][r] = "<<pnt[use[j]][r]<<"\n";
- fct *= pnt[use[j]][r];
- fct %= inf;
- }
- res += fct;
- res %= inf;
- }//cout<<"\n";
- return res;
- }
- int main()
- {
- /*ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);*/
- cin>>d;
- qn.resize(d); ax.resize(d);
- for (int &x: ax) cin>>x;
- for (int &x: qn) cin>>x;
- int mx = *max_element(ax.begin(), ax.end());
- pnt.resize(d, vector <int> (mx+1, 0));
- //cout<<"pnt\n";
- //cvv(pnt);
- for (int r = 1; r <= mx; ++r){
- for (int i = 0; i < d; ++i){
- /*cout<<"i r = "<<i<<' '<<r<<"\n";
- cout<<"qn[i] - r = "<<qn[i] - r<<"\n";
- cout<<"qn[i] + r = "<<qn[i] + r<<"\n";*/
- if (qn[i] - r > 0) {
- pnt[i][r]++;
- //cout<<"++\n";
- }
- if (qn[i] + r <= ax[i]) {
- //cout<<"++\n";
- pnt[i][r]++;
- }
- }
- }
- //cvv(pnt);
- for (int msk = 1; msk < (1<<d);++msk){
- ans += pl(msk);
- ans %= inf;
- }
- cout<<ans<<"\n";
- }
- /*
- 1 9 6
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement