답안 #748493

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
748493 2023-05-26T11:13:26 Z Trunkty Sob (COCI19_sob) C++14
39 / 110
132 ms 113836 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

int n,m,l,r,curr;
vector<vector<int>> ans;
vector<int> a;
vector<int> b[3000005];

signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);
    cin >> n >> m;
    for(int i=0;i<=n-1;i++){
        a.push_back(i);
    }
    for(int i=m;i<=m+n-1;i++){
        b[i].push_back(i);
    }
    for(int j=20;j>=0;j--){
        while(a.size()>0 and a.back()&(1<<j)){
            int x = a.back();
            a.pop_back();
            int y;
            if(b[x].size()==0){
                for(int k=1;k<=2e6;k++){
                    if(b[x&k].size()>0){
                        y = b[x&k].back();
                        b[x&k].pop_back();
                        break;
                    }
                }
            }
            else{
                y = b[x].back();
                b[x].pop_back();
            }
            ans.push_back({x,y});
        }
        for(int i=(1<<j);i<(1<<(j+1));i++){
            for(int k:b[i]){
                b[i-(1<<j)].push_back(k);
            }
            b[i].clear();
        }
    }
    ans.push_back({a.back(),b[0][0]});
    for(vector<int> i:ans){
        cout << i[0] << " " << i[1] << "\n";
    }
    return 0;
}

Compilation message

sob.cpp: In function 'int main()':
sob.cpp:39:32: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |             ans.push_back({x,y});
      |                                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 70772 KB Output is correct
2 Correct 39 ms 70716 KB Output is correct
3 Correct 39 ms 70740 KB Output is correct
4 Correct 132 ms 113836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 71124 KB Output is correct
2 Correct 41 ms 70672 KB Output is correct
3 Correct 39 ms 70656 KB Output is correct
4 Correct 45 ms 70664 KB Output is correct
5 Correct 40 ms 70720 KB Output is correct
6 Correct 124 ms 107120 KB Output is correct
7 Correct 83 ms 92332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 70736 KB Output is correct
2 Incorrect 47 ms 70768 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 70772 KB Output is correct
2 Correct 39 ms 70716 KB Output is correct
3 Correct 39 ms 70740 KB Output is correct
4 Correct 132 ms 113836 KB Output is correct
5 Correct 39 ms 71124 KB Output is correct
6 Correct 41 ms 70672 KB Output is correct
7 Correct 39 ms 70656 KB Output is correct
8 Correct 45 ms 70664 KB Output is correct
9 Correct 40 ms 70720 KB Output is correct
10 Correct 124 ms 107120 KB Output is correct
11 Correct 83 ms 92332 KB Output is correct
12 Correct 41 ms 70736 KB Output is correct
13 Incorrect 47 ms 70768 KB Output isn't correct
14 Halted 0 ms 0 KB -