Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- #define read() freopen("input.txt", "r", stdin)
- #define write() freopen("output.txt", "w", stdout)
- void fastIO()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- }
- int main()
- {
- //read();
- //write();
- fastIO();
- map< string , pair< pair< int , int > , pair< int, vector< pair< int, int > > > > > mp;
- int n,m;
- cin>>n>>m;
- for(int i=0;i<n;i++){
- string s;
- cin>>s;
- int x,y,z;
- cin>>x>>y>>z;
- vector< pair<int,int> > v;
- for(int j=0;j<z;j++){
- int a,b;
- cin>>a>>b;
- v.push_back(make_pair(a,b));
- }
- mp[s] = make_pair(make_pair(x,y),make_pair(z,v));
- }
- for(int i=0;i<m;i++){
- string s;
- cin>>s;
- cout<<s<<"[";
- int x,y,z;
- x = mp[s].first.first;
- y = mp[s].first.second;
- z = mp[s].second.first;
- vector< pair<int,int> > v;
- v = mp[s].second.second;
- vector<int>t;
- for(int j=0;j<z;j++){
- if(j) cout<<", ";
- int a;
- cin>>a;
- cout<<a;
- t.push_back(a);
- }
- cout<<"] = ";
- int total = x,next = 1;
- for(int j=z-1;j>=0;j--){
- int u,d,a,diff;
- u = v[j].second;
- d = v[j].first;
- diff = u - d + 1;
- a = t[j] - d;
- a*=y;
- a*=next;
- total+=a;
- next*=diff;
- }
- cout<<total<<'\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement