Submission #202651

# Submission time Handle Problem Language Result Execution time Memory
202651 2020-02-17T15:05:36 Z SorahISA Sob (COCI19_sob) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int maxn = 1 << 20;

vector<int> v(maxn);

int32_t main() {
    fastIO();
    
    int n, m;
    cin >> n >> m;
    
    /// for subtask 1 : n == 2^k ///
    
    if ((1 << __lg(n)) == n) {
        for (int i = m+n-1; i >= m; --i) {
            if (((n-1) & i) == (n-1)) {tok = i+1-n; break;}
        }
        
        for (int i = 0; i < n; ++i) {
            cout << i << " " << (tok+i < m ? tok+i+n : tok+i) << "\n";
        }
        
        return 0;
    }
    
    /// for subtask 2 : n+m == 2^k ///
    
    int now = 1, p;
    for (int i = 1; i < n; ++i) {
        now = (now ? now - 1 : i - 1);
        p = now;
        while (v[now]) {
            swap(v[now], v[p]);
            p += (1 << (int)__lg(v[now]) + 1);
        }
        v[now] = i;
    }
    
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; ++i) ans.push_back({v[i], n+m-i-1});
    sort(ans.begin(), ans.end());
    
    for (auto [L, R] : ans) cout << L << " " << R << "\n";
    
    return 0;
}

Compilation message

sob.cpp: In function 'int32_t main()':
sob.cpp:23:40: error: 'tok' was not declared in this scope
             if (((n-1) & i) == (n-1)) {tok = i+1-n; break;}
                                        ^~~
sob.cpp:27:34: error: 'tok' was not declared in this scope
             cout << i << " " << (tok+i < m ? tok+i+n : tok+i) << "\n";
                                  ^~~
sob.cpp:41:42: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
             p += (1 << (int)__lg(v[now]) + 1);
                        ~~~~~~~~~~~~~~~~~~^~~
sob.cpp:50:15: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
     for (auto [L, R] : ans) cout << L << " " << R << "\n";
               ^