#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <iostream>
#include <string>
#include <ctime>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pci pair<char,int>
#define pdd pair<double,double>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pdi pair<double,int>
#define pdd pair<double,double>
#define mod 1000000007
#define mod1 1000000009
#define mod2 1000000021
#define INF 2000000001
#define MAX 9000001
long double PI = 3.141592653589793238462643383279502884197;
using namespace std;
/* 🐣🐥 */
int ans[500001];
map<int, int> mp, tmp;
int main() {
int n, m, t = 1;
scanf("%d %d", &n, &m);
while (t <= n) t <<= 1;
for (int i = m; i < m + n; i++)
mp[i % t] = i;
for (t >>= 1; ; t >>= 1) {
for (int i = 0; i < n; i++) {
if (ans[i]) continue;
if (mp.find(i % t) != mp.end()) {
ans[i] = mp[i % t];
mp.erase(i % t);
}
else if(mp.find(i%t|t) != mp.end()){
ans[i] = mp[i%t | t];
mp.erase(i%t |t);
}
}
if (!t) break;
tmp.clear();
for (auto iter = mp.begin(); iter != mp.end(); ++iter) {
tmp[iter->first % t] = iter->second;
}
mp = tmp;
}
for (int i = 0; i < n; i++)
printf("%d %d\n", i, ans[i]);
}
Compilation message
sob.cpp: In function 'int main()':
sob.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &m);
~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
194 ms |
17264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
153 ms |
17272 KB |
Output is correct |
7 |
Correct |
81 ms |
8440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
194 ms |
17264 KB |
Output is correct |
5 |
Correct |
7 ms |
504 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
153 ms |
17272 KB |
Output is correct |
11 |
Correct |
81 ms |
8440 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
39 ms |
3808 KB |
Output is correct |
20 |
Correct |
126 ms |
13044 KB |
Output is correct |
21 |
Correct |
8 ms |
760 KB |
Output is correct |
22 |
Correct |
6 ms |
504 KB |
Output is correct |
23 |
Correct |
203 ms |
18552 KB |
Output is correct |
24 |
Correct |
346 ms |
32632 KB |
Output is correct |
25 |
Correct |
329 ms |
32172 KB |
Output is correct |