Submission #676457

# Submission time Handle Problem Language Result Execution time Memory
676457 2022-12-31T02:46:20 Z vjudge1 Cake (CEOI14_cake) C++17
Compilation error
0 ms 0 KB
    #include <bits/stdc++.h>
     
    using namespace std;
    typedef pair<int,int> pii;
    int n,q,a,d[300005],where[300005];
    set<pii> s;
    void compute()
    {
        where[a]=1;
        int st=a-1;
        int dr=a+1;
        int cnt=1;
        while(st>0||dr<=n)
        {
            cnt++;
            if(d[st]<d[dr])
            {
                where[st]=cnt;
                st--;
            }
            else
            {
                where[dr]=cnt;
                dr++;
            }
        }
    }
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cin>>n>>a;
        for(int i=1;i<=n;i++)
        {
            cin>>d[i];
            s.insert({d[i],i});
        }
        d[0]=d[n+1]=1e9;
        compute();
        cin>>q;
        while(q--)
        {
            char c;
            cin>>c;
            if(c=='F')
            {
                int poz;
                cin>>poz;
                cout<<where[poz]-1<<'\n';
            }
            else
            {
                int poz,val;
                cin>>poz>>val;
                int old=d[poz];
                vector<int> mypoz;
                auto it=prev(s.end());
                int cnt=0;
                int myval=0;
                while(cnt+1<val)
                {
                    cnt++;
                    int p=(*it).second;
                    myval=(*it).first;
                    mypoz.push_back(p);
                    it--;
                }
                if(myval==0)
                    myval=(*it).first+1;
                s.erase({d[poz],poz});
                d[poz]=myval;
                s.insert({d[poz],poz});
                for(auto i:mypoz)
                {
                    s.erase({d[i],i});
                    d[i]++;
                    s.insert({d[i],i});
                }
                compute();
            }
        }
        return 0;
    }

Compilation message

cake.cpp:2:5: error: extended character   is not valid in an identifier
    2 |      
      |     ^
cake.cpp:2:5: error: '\U000000a0' does not name a type
    2 |      
      |     ^
cake.cpp:4:13: error: 'pair' does not name a type
    4 |     typedef pair<int,int> pii;
      |             ^~~~
cake.cpp:6:5: error: 'set' does not name a type; did you mean 'setns'?
    6 |     set<pii> s;
      |     ^~~
      |     setns
cake.cpp: In function 'int main()':
cake.cpp:30:9: error: 'ios_base' has not been declared
   30 |         ios_base::sync_with_stdio(false);
      |         ^~~~~~~~
cake.cpp:31:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   31 |         cin.tie(0);
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from cake.cpp:1:
/usr/include/c++/10/iostream:60:18: note: 'std::cin' declared here
   60 |   extern istream cin;  /// Linked to standard input
      |                  ^~~
cake.cpp:36:13: error: 's' was not declared in this scope
   36 |             s.insert({d[i],i});
      |             ^
cake.cpp:49:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   49 |                 cout<<where[poz]-1<<'\n';
      |                 ^~~~
      |                 std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from cake.cpp:1:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
cake.cpp:56:17: error: 'vector' was not declared in this scope
   56 |                 vector<int> mypoz;
      |                 ^~~~~~
cake.cpp:56:17: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cake.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cake.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
cake.cpp:56:24: error: expected primary-expression before 'int'
   56 |                 vector<int> mypoz;
      |                        ^~~
cake.cpp:57:30: error: 's' was not declared in this scope
   57 |                 auto it=prev(s.end());
      |                              ^
cake.cpp:57:25: error: 'prev' was not declared in this scope; did you mean 'std::prev'?
   57 |                 auto it=prev(s.end());
      |                         ^~~~
      |                         std::prev
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cake.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: 'std::prev' declared here
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
cake.cpp:65:21: error: 'mypoz' was not declared in this scope; did you mean 'poz'?
   65 |                     mypoz.push_back(p);
      |                     ^~~~~
      |                     poz
cake.cpp:73:28: error: 'mypoz' was not declared in this scope; did you mean 'poz'?
   73 |                 for(auto i:mypoz)
      |                            ^~~~~
      |                            poz
cake.cpp:55:21: warning: unused variable 'old' [-Wunused-variable]
   55 |                 int old=d[poz];
      |                     ^~~