Submission #701829

#TimeUsernameProblemLanguageResultExecution timeMemory
701829Darren0724The Potion of Great Power (CEOI20_potion)C++17
Compilation error
0 ms0 KiB
/*#include <bits/stdc++.h> using namespace std;*/ void init(int N, int D, int F[]); void curseChanges(int U, int A[], int B[]); int question(int X, int Y, int V); int n; vector<int> h; struct cmp{ bool operator()(const int &a,const int &b){ return h[a]<h[b]; } }; vector<map<int,set<int,cmp>>> s; void init(int N, int D, int H[]) { n=N; h.resize(n); s.resize(n); for(int i=0;i<n;i++){ h[i]=H[i]; } set<int,cmp> a1; for(int i=0;i<n;i++){ s[i][0]=a1; } } void curseChanges(int U, int A[], int B[]) { for(int i=1;i<=U;i++){ int a=A[i-1]; int b=B[i-1]; set<int,cmp> a1=(--s[a].end())->second; set<int,cmp> b1=(--s[b].end())->second; if(a1.find(b)==a1.end()){ a1.insert(b); b1.insert(a); } else{ a1.erase(b); b1.erase(a); } s[a][i]=a1; s[b][i]=b1; } for(int i=0;i<n;i++){ for(auto j:s[i]){ cout<<i<<' '<<j.first<<':'; for(int k:j.second){ cout<<k<<' '; } cout<<endl; } } } int question(int x, int y, int v) { set<int,cmp> s1; set<int,cmp> a=(--s[x].upper_bound(v))->second; set<int,cmp> b=(--s[y].upper_bound(v))->second; auto it=a.begin(); auto it1=b.begin(); int ans=1000000000; while(it!=a.end()&&it1!=b.end()){ cout<<*it<<' '<<*it1<<endl; ans=min(ans,abs(h[*it]-h[*it1])); if(h[*it]<h[*it1]){ it++; } else{ it1++; } } return ans; }

Compilation message (stderr)

potion.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int> h;
      | ^~~~~~
potion.cpp: In member function 'bool cmp::operator()(const int&, const int&)':
potion.cpp:10:16: error: 'h' was not declared in this scope
   10 |         return h[a]<h[b];
      |                ^
potion.cpp: At global scope:
potion.cpp:13:1: error: 'vector' does not name a type
   13 | vector<map<int,set<int,cmp>>> s;
      | ^~~~~~
potion.cpp: In function 'void init(int, int, int*)':
potion.cpp:16:5: error: 'h' was not declared in this scope
   16 |     h.resize(n);
      |     ^
potion.cpp:17:5: error: 's' was not declared in this scope
   17 |     s.resize(n);
      |     ^
potion.cpp:21:5: error: 'set' was not declared in this scope
   21 |     set<int,cmp> a1;
      |     ^~~
potion.cpp:21:9: error: expected primary-expression before 'int'
   21 |     set<int,cmp> a1;
      |         ^~~
potion.cpp:23:17: error: 'a1' was not declared in this scope
   23 |         s[i][0]=a1;
      |                 ^~
potion.cpp: In function 'void curseChanges(int, int*, int*)':
potion.cpp:31:9: error: 'set' was not declared in this scope
   31 |         set<int,cmp> a1=(--s[a].end())->second;
      |         ^~~
potion.cpp:31:13: error: expected primary-expression before 'int'
   31 |         set<int,cmp> a1=(--s[a].end())->second;
      |             ^~~
potion.cpp:32:13: error: expected primary-expression before 'int'
   32 |         set<int,cmp> b1=(--s[b].end())->second;
      |             ^~~
potion.cpp:33:12: error: 'a1' was not declared in this scope; did you mean 'a'?
   33 |         if(a1.find(b)==a1.end()){
      |            ^~
      |            a
potion.cpp:35:13: error: 'b1' was not declared in this scope; did you mean 'b'?
   35 |             b1.insert(a);
      |             ^~
      |             b
potion.cpp:39:13: error: 'b1' was not declared in this scope; did you mean 'b'?
   39 |             b1.erase(a);
      |             ^~
      |             b
potion.cpp:41:9: error: 's' was not declared in this scope
   41 |         s[a][i]=a1;
      |         ^
potion.cpp:41:17: error: 'a1' was not declared in this scope; did you mean 'a'?
   41 |         s[a][i]=a1;
      |                 ^~
      |                 a
potion.cpp:42:17: error: 'b1' was not declared in this scope; did you mean 'b'?
   42 |         s[b][i]=b1;
      |                 ^~
      |                 b
potion.cpp:45:20: error: 's' was not declared in this scope
   45 |         for(auto j:s[i]){
      |                    ^
potion.cpp:46:13: error: 'cout' was not declared in this scope
   46 |             cout<<i<<' '<<j.first<<':';
      |             ^~~~
potion.cpp:50:19: error: 'endl' was not declared in this scope
   50 |             cout<<endl;
      |                   ^~~~
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:56:5: error: 'set' was not declared in this scope
   56 |     set<int,cmp> s1;
      |     ^~~
potion.cpp:56:9: error: expected primary-expression before 'int'
   56 |     set<int,cmp> s1;
      |         ^~~
potion.cpp:57:9: error: expected primary-expression before 'int'
   57 |     set<int,cmp> a=(--s[x].upper_bound(v))->second;
      |         ^~~
potion.cpp:58:9: error: expected primary-expression before 'int'
   58 |     set<int,cmp> b=(--s[y].upper_bound(v))->second;
      |         ^~~
potion.cpp:59:13: error: 'a' was not declared in this scope
   59 |     auto it=a.begin();
      |             ^
potion.cpp:60:14: error: 'b' was not declared in this scope
   60 |     auto it1=b.begin();
      |              ^
potion.cpp:63:9: error: 'cout' was not declared in this scope
   63 |         cout<<*it<<' '<<*it1<<endl;
      |         ^~~~
potion.cpp:63:31: error: 'endl' was not declared in this scope
   63 |         cout<<*it<<' '<<*it1<<endl;
      |                               ^~~~
potion.cpp:64:25: error: 'h' was not declared in this scope
   64 |         ans=min(ans,abs(h[*it]-h[*it1]));
      |                         ^
potion.cpp:64:21: error: 'abs' was not declared in this scope; did you mean 'ans'?
   64 |         ans=min(ans,abs(h[*it]-h[*it1]));
      |                     ^~~
      |                     ans
potion.cpp:64:13: error: 'min' was not declared in this scope
   64 |         ans=min(ans,abs(h[*it]-h[*it1]));
      |             ^~~