Advertisement
Korotkodul

C_62

Dec 31st, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <string>
  7. #include <stack>
  8. #include <set>
  9. #include <map>
  10. #define pii pair <int,int>
  11. using namespace std;
  12. using ll = long long;
  13. using ld = long double;
  14. void cv(vector <int> &v){
  15.     for (auto x: v) cout<<x<<' ';
  16.     cout<<"\n";
  17. }
  18.  
  19. void cvv(vector <vector<int>> &v){
  20.     for (auto x: v) cv(x);
  21.     cout<<"\n";
  22. }
  23. int inf = 998244353, ans=0;
  24. int d;
  25. vector <int> qn;
  26. vector <int> ax;
  27. vector <vector <int> > pnt; //points at the distance  = r
  28.  
  29. int pl(int msk){
  30.     //cout<<"msk = "<<msk<<"\n";
  31.     int res = 0;
  32.     vector <int> use;
  33.     for (int i = 0; i < d; ++i){
  34.         if (msk & (1 << i)){
  35.             use.push_back(i);
  36.         }
  37.     }
  38.     /*cout<<"use\n";
  39.     cv(use);
  40.     cout<<"pnt.size() = "<<pnt.size()<<"\n";*/
  41.     for (int r = 1; r < pnt[0].size(); ++r){
  42.         int fct = 1;
  43.         //cout<<"r = "<<r<<"\n";
  44.         for (int j = 0; j < use.size();++j){
  45.             //cout<<"r use[j] = "<<r<<' '<<use[j]<<"\n";
  46.             //cout<<"pnt[use[j]][r] = "<<pnt[use[j]][r]<<"\n";
  47.             fct *= pnt[use[j]][r];
  48.             fct %= inf;
  49.         }
  50.         res += fct;
  51.         res %= inf;
  52.     }//cout<<"\n";
  53.     return res;
  54. }
  55.  
  56. int main()
  57. {
  58.     /*ios::sync_with_stdio(0);
  59.     cin.tie(0);
  60.     cout.tie(0);*/
  61.     cin>>d;
  62.     qn.resize(d); ax.resize(d);
  63.     for (int &x: ax) cin>>x;
  64.     for (int &x: qn) cin>>x;
  65.     int mx = *max_element(ax.begin(), ax.end());
  66.     pnt.resize(d, vector <int> (mx+1, 0));
  67.     //cout<<"pnt\n";
  68.     //cvv(pnt);
  69.     for (int r = 1; r <= mx; ++r){
  70.         for (int i = 0; i < d; ++i){
  71.             /*cout<<"i r = "<<i<<' '<<r<<"\n";
  72.             cout<<"qn[i] - r = "<<qn[i] - r<<"\n";
  73.             cout<<"qn[i] + r = "<<qn[i] + r<<"\n";*/
  74.             if (qn[i] - r > 0) {
  75.                     pnt[i][r]++;
  76.                     //cout<<"++\n";
  77.             }
  78.             if (qn[i] + r <= ax[i]) {
  79.                     //cout<<"++\n";
  80.                     pnt[i][r]++;
  81.             }
  82.         }
  83.     }
  84.     //cvv(pnt);
  85.     for (int msk = 1; msk < (1<<d);++msk){
  86.         ans += pl(msk);
  87.         ans %= inf;
  88.     }
  89.     cout<<ans<<"\n";
  90. }
  91. /*
  92. 1 9 6
  93. */
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement