Submission #520247

# Submission time Handle Problem Language Result Execution time Memory
520247 2022-01-29T02:12:35 Z christinelynn Swap (BOI16_swap) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
#define debug(y cout<<y,exit(0
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 2e5 + 9;
const ll inf = 1e9 + 7;
 
vector<ll> dp[N[18[2;
                  ll n,a[N;
                        bool need[N[18[2;
                                       
                                      void Merge(vector<ll> &res,vector<ll> &a,vector<ll> &b{
                                            for (ll i = 0,j = 1;i < a.size(;i += j,j *= 2{
                                                      for (ll k = i;k < i + j && k < a.size(;k++ res.push_back(a[k;
                                                                                                                        for (ll k = i;k < i + j && k < b.size(;k++ res.push_back(b[k;
                                                                                                                            
                                                                                                                            
                                                                                                                             
                                                                                                                             int main({
                                                                                                                                   ios_base::sync_with_stdio(NULL; cin.tie(0; cout.tie(0;
                                                                                                                                       #define task "test"
                                                                                                                                           if (fopen(task".inp","r"{
                                                                                                                                                     freopen(task".inp","r",stdin;
                                                                                                                                                             //freopen(task".out","w",stdout;
                                                                                                                                                                 
                                                                                                                                                                     cin>>n;
                                                                                                                                                                         for (ll i = 1;i <= n;i++ cin>>a[i;
                                                                                                                                                                             need[1[0[1 = 1;
                                                                                                                                                                              
                                                                                                                                                                                  for (ll node = 1;node <= n/2;node++{
                                                                                                                                                                                          for (ll i = 0;node >> i;i++{
                                                                                                                                                                                                      for (auto j : {0,1{
                                                                                                                                                                                                                      if (!need[node[i[j continue;
                                                                                                                                                                                                                                      ll p = ((node >> i + 1 << 1 + j;
                                                                                                                                                                                                                                                      ll mn = min({a[p,a[node*2,a[node*2 + 1;
                                                                                                                                                                                                                                                                      if (mn == a[node*2
                                                                                                                                                                                                                                                                                          need[2*node[i + 1[j = need[2*node + 1[0[1 = 1;
                                                                                                                                                                                                                                                                                                          else if (mn == a[p
                                                                                                                                                                                                                                                                                                                              need[2*node[0[0 = need[2*node + 1[0[1 = 1;
                                                                                                                                                                                                                                                                                                                                              else
                                                                                                                                                                                                                                                                                                                                                                  need[2*node[0[0 = need[2*node + 1[0[0 = 1,
                                                                                                                                                                                                                                                                                                                                                                                      need[2*node[i + 1[j = need[2*node + 1[i + 1[j = 1;
                                                                                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                   for (ll node = n;node;node--{
                                                                                                                                                                                                                                                                                                                                                                                                                           for (ll i = 0;node >> i;i++{
                                                                                                                                                                                                                                                                                                                                                                                                                                       for (auto j : {0,1{
                                                                                                                                                                                                                                                                                                                                                                                                                                                       if (!need[node[i[j continue;
                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ll p = ((node >> i + 1 << 1 + j;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        if (2*node > n dp[node[i[j = {a[p;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        else if (2*node == n dp[node[i[j = {min(a[p,a[node*2,max(a[p,a[node*2;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        else{
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ll mn = min({a[p,a[2*node,a[2*node + 1;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                if (mn == a[2*node + 1{
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        vector<ll> tmp1,tmp2; tmp1 = tmp2 = {a[2*node + 1;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Merge(tmp1,dp[2*node[0[0,dp[2*node + 1[i + 1[j;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Merge(tmp2,dp[2*node[i + 1[j,dp[2*node + 1[0[0;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                dp[node[i[j = min(tmp1,tmp2;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        else{
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                dp[node[i[j = {min(a[p,a[2*node;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        if (mn == a[p
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Merge(dp[node[i[j,dp[2*node[0[0,dp[2*node + 1[0[1;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            else
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Merge(dp[node[i[j,dp[2*node[i + 1[j,dp[2*node + 1[0[1;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        if (2*node < n{
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    for (ll i = 0;2*node >> i;i++{
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    for (auto j : {0,1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        vector<ll>(.swap(dp[2*node[i[j,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            vector<ll>(.swap(dp[2*node + 1[i[j;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        for (auto i : dp[1[0[1 cout<<i<<" ";
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         /* stuff you should look for
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           * int overflow, array bounds
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             * special cases (n=1?
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               * do smth instead of nothing and stay organized
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * WRITE STUFF DOWN
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   * DON'T GET STUCK ON ONE APPROACH
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   */)]]])]]]))]]]))})
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    })
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        })]]]]]]]]])]]]]]]]]])])]])}]]]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        })]]]]]]]]])]]]]]])]}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }])]]]})
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        }]])]])}]]])]}]]])))]]])
                                                                                                                                                                                                                                                                                                                                                                                                                                       }})
                                                                                                                                                                                                                                                                                                                                                                                                                           })
                                                                                                                                                                                                                                                                                                                                                                                                                   })]]]]]]]]]]]]]]]]]]])]]]]]]])]]]})))]]])
                                                                                                                                                                                                      }})
                                                                                                                                                                                          })
                                                                                                                                                                                  })]]]])))
                                                                                                                                           })))))
                                                                                                                             })])))])))
                                            }))
                                      })]]]]]]]))

Compilation message

swap.cpp:6:17: error: expected ',' or ')', found "cout"
    6 | #define debug(y cout<<y,exit(0
      |                 ^~~~
swap.cpp:12:21: error: expected ']' before ';' token
   12 | vector<ll> dp[N[18[2;
      |                     ^
      |                     ]
swap.cpp:12:19: error: invalid types 'int[int]' for array subscript
   12 | vector<ll> dp[N[18[2;
      |                   ^
swap.cpp:12:21: error: expected ']' before ';' token
   12 | vector<ll> dp[N[18[2;
      |                     ^
      |                     ]
swap.cpp:12:21: error: expected ']' before ';' token
   12 | vector<ll> dp[N[18[2;
      |                     ^
      |                     ]
swap.cpp:13:27: error: expected ']' before ';' token
   13 |                   ll n,a[N;
      |                           ^
      |                           ]
swap.cpp:14:41: error: expected ']' before ';' token
   14 |                         bool need[N[18[2;
      |                                         ^
      |                                         ]
swap.cpp:14:39: error: invalid types 'int[int]' for array subscript
   14 |                         bool need[N[18[2;
      |                                       ^
swap.cpp:14:41: error: expected ']' before ';' token
   14 |                         bool need[N[18[2;
      |                                         ^
      |                                         ]
swap.cpp:14:41: error: expected ']' before ';' token
   14 |                         bool need[N[18[2;
      |                                         ^
      |                                         ]
swap.cpp:16:93: error: expected ')' before '{' token
   16 |                                       void Merge(vector<ll> &res,vector<ll> &a,vector<ll> &b{
      |                                                 ~                                           ^
      |                                                                                             )
swap.cpp: In function 'void Merge(std::vector<int>&, std::vector<int>&, std::vector<int>&)':
swap.cpp:17:76: error: expected primary-expression before ';' token
   17 |                                             for (ll i = 0,j = 1;i < a.size(;i += j,j *= 2{
      |                                                                            ^
swap.cpp:17:90: error: expected ')' before '{' token
   17 |                                             for (ll i = 0,j = 1;i < a.size(;i += j,j *= 2{
      |                                                 ~                                        ^
      |                                                                                          )
swap.cpp:18:93: error: expected primary-expression before ';' token
   18 |                                                       for (ll k = i;k < i + j && k < a.size(;k++ res.push_back(a[k;
      |                                                                                             ^
swap.cpp:18:97: error: expected ')' before 'res'
   18 |                                                       for (ll k = i;k < i + j && k < a.size(;k++ res.push_back(a[k;
      |                                                           ~                                     ^~~~
      |                                                                                                 )
swap.cpp:18:115: error: expected ']' before ';' token
   18 |                                                       for (ll k = i;k < i + j && k < a.size(;k++ res.push_back(a[k;
      |                                                                                                                   ^
      |                                                                                                                   ]
swap.cpp:18:115: error: expected ')' before ';' token
   18 |                                                       for (ll k = i;k < i + j && k < a.size(;k++ res.push_back(a[k;
      |                                                                                                               ~   ^
      |                                                                                                                   )
swap.cpp:19:159: error: expected primary-expression before ';' token
   19 |                                                                                                                         for (ll k = i;k < i + j && k < b.size(;k++ res.push_back(b[k;
      |                                                                                                                                                               ^
swap.cpp:19:163: error: expected ')' before 'res'
   19 |                                                                                                                         for (ll k = i;k < i + j && k < b.size(;k++ res.push_back(b[k;
      |                                                                                                                             ~                                     ^~~~
      |                                                                                                                                                                   )
swap.cpp:19:181: error: expected ']' before ';' token
   19 |                                                                                                                         for (ll k = i;k < i + j && k < b.size(;k++ res.push_back(b[k;
      |                                                                                                                                                                                     ^
      |                                                                                                                                                                                     ]
swap.cpp:19:181: error: expected ')' before ';' token
   19 |                                                                                                                         for (ll k = i;k < i + j && k < b.size(;k++ res.push_back(b[k;
      |                                                                                                                                                                                 ~   ^
      |                                                                                                                                                                                     )
swap.cpp:24:162: error: expected ')' before ';' token
   24 |                                                                                                                                    ios_base::sync_with_stdio(NULL; cin.tie(0; cout.tie(0;
      |                                                                                                                                                             ~    ^
swap.cpp:24:162: error: expected '}' before ';' token
swap.cpp:23:135: note: to match this '{'
   23 |                                                                                                                              int main({
      |                                                                                                                                       ^
swap.cpp:24:162: error: expected ')' before ';' token
   24 |                                                                                                                                    ios_base::sync_with_stdio(NULL; cin.tie(0; cout.tie(0;
      |                                                                                                                                                                  ^
swap.cpp:23:134: note: to match this '('
   23 |                                                                                                                              int main({
      |                                                                                                                                      ^
swap.cpp:24:173: error: expected ')' before ';' token
   24 |                                                                                                                                    ios_base::sync_with_stdio(NULL; cin.tie(0; cout.tie(0;
      |                                                                                                                                                                           ~ ^
      |                                                                                                                                                                             )
swap.cpp:24:185: error: expected ')' before ';' token
   24 |                                                                                                                                    ios_base::sync_with_stdio(NULL; cin.tie(0; cout.tie(0;
      |                                                                                                                                                                                       ~ ^
      |                                                                                                                                                                                         )
swap.cpp:26:164: error: expected ')' before '{' token
   26 |                                                                                                                                            if (fopen(task".inp","r"{
      |                                                                                                                                                     ~              ^
      |                                                                                                                                                                    )
swap.cpp:106:143: error: expected primary-expression before ')' token
  106 |                                                                                                                                            })))))
      |                                                                                                                                               ^
swap.cpp:23:130: warning: unused variable 'main' [-Wunused-variable]
   23 |                                                                                                                              int main({
      |                                                                                                                                  ^~~~
swap.cpp:107:127: error: expected primary-expression before ')' token
  107 |                                                                                                                              })])))])))
      |                                                                                                                               ^
swap.cpp: At global scope:
swap.cpp:108:46: error: expected unqualified-id before ')' token
  108 |                                             }))
      |                                              ^
swap.cpp:109:39: error: expected declaration before '}' token
  109 |                                       })]]]]]]]))
      |                                       ^
swap.cpp:109:40: error: expected unqualified-id before ')' token
  109 |                                       })]]]]]]]))
      |                                        ^