#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) != mp.end()) {
ans[i] = mp[i];
mp.erase(i);
}
else if(mp.find(i|t) != mp.end()){
ans[i] = mp[i | t];
mp.erase(i|t);
}
}
if (!t) break;
}
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 |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
183 ms |
17272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
504 KB |
Integer parameter [name=y] equals to 0, violates the range [4815, 8191] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Integer parameter [name=y] equals to 0, violates the range [647, 886] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
183 ms |
17272 KB |
Output is correct |
5 |
Incorrect |
6 ms |
504 KB |
Integer parameter [name=y] equals to 0, violates the range [4815, 8191] |
6 |
Halted |
0 ms |
0 KB |
- |