Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // #### Zeinab
- #include<bits/stdc++.h>
- using namespace std;
- #define nl "\n"
- #define fi first
- #define se second
- #define pb push_back
- #define ll long long
- #define RV return void
- #define sz(x) int(x.size())
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #define cin(v) for(auto&x:v) cin >> x;
- #define cout(v) for(auto&x:v) cout << x << " ";
- int dx[] = {-2 , -2 , 2 , 2 , 1 , 1 , -1 , -1};
- int dy[] = {-1 , 1 , -1 , 1 , -2 , 2 , -2 , 2};
- bool valid(int i , int j){
- return i >=0 and j >=0 and i < 8 and j < 8;
- }
- string s , sp;
- bool comp(string a , string b){
- if(sz(a) == sz(b))
- return a < b;
- return sz(a) < sz(b);
- }
- void solve(){
- bool ok =1;
- vector < string > v;
- map < string , int > mp;
- int t=0;
- while(cin >> s ){
- if(s =="()"){
- if(t > 0) cout << nl;
- t++;
- sort(all(v) , comp);
- for(auto& x : v){
- if( mp.find(x.substr(0 , sz(x) - 1)) == mp.end()){
- ok=0;
- break;
- }
- }
- if(!ok) {
- cout <<"not complete";
- }else{
- for(int i =0 ; i < sz(v) ; i++){
- if(i ) cout << " ";
- cout << mp[v[i]] ;
- }
- }
- v.clear();
- mp.clear();
- ok=1;
- }
- else{
- int n = sz(s);
- for(int i =0 ; i < n ; i++){
- if(s[i]=='(' ){
- int num =0;
- i++;
- while(i < n and s[i] !=',') num = num * 10 + (s[i++] -'0');
- string temp = "";
- i++;
- while(i < n and s[i] != ')') temp += s[i++];
- mp[temp]=num;
- v.pb(temp);
- }
- }
- }
- }
- }
- int main(){
- ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
- int t=1;
- // cin >> t ;
- for(int i=1 ; i <= t ; i++){
- // cout << "Case "<< i <<": " ;
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement