Submission #52318321
Source Code Expand
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define get(T,args...) T args; read(args);
#define init(a,T,n,s) vector<T> a((n)+1,s); cin>>a;
#define putn(args...) { put(args); cout<<"\n"; }
#define pute(args...) { put(args); cout<<endl; }
#define putr(args...) { putn(args) return ;}
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define repr(i,a,b) for(int i=(a); i>(b); i--)
#define logarr(arr,f,l) { auto start=arr.begin(), end=arr.begin(); advance(start,(f)); advance(end,(l)); for(auto it=start; it!=end; it++) cout<<*it<<" "; cout<<"\n"; }
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sort_by(span,p) sort(span, [&](const auto &l, const auto &r) { return p; })
#define f(u, args...) [&](auto &&u) { return args; }
#define g(u, v, args...) [&](auto &&u, auto &&v) { return args; }
#define uniq(x) x.erase(unique(all(x)),x.end());
#define sz(x) (int)(x).size()
#define mid(l,r) std::midpoint((l),(r))
#define zov(v,z,c) ((c) ? (v) : (z))
#define pii pair<int,int>
#define pb emplace_back
#define pf push_front
#define fr first
#define sc second
#define sumv(v,b,e) accumulate((v).begin()+b,(v).begin()+e,0LL)
#define minv(v,b,e) min_element((v).begin()+b,(v).begin()+e)
#define maxv(v,b,e) max_element((v).begin()+b,(v).begin()+e)
#define precise(n) cout<<fixed<<setprecision((n))
#define bpc(n) std::popcount((unsigned long long)(n))
#define hsb(n) std::has_single_bit((unsigned long long)(n))
#define MSB(n) std::bit_floor((unsigned long long)(n))
#define ctz(n) ((n) ? __builtin_ctzll((unsigned long long)(n)) : 0)
#define clz(n) ((n) ? __builtin_clzll((unsigned long long)(n)) : 64)
#define LSB(n) ((n) ? ((n)&(-(n))) : 1LL<<61)
#define vec(args...) std::vector<args>
#define set(args...) std::set<args,Comp<args> >
#define pqueue(args...) std::priority_queue<args,vector<args>,Comp<args> >
#define oset(args...) tree<args, null_type, less<args>, rb_tree_tag, tree_order_statistics_node_update>
constexpr int N = 100'001, M = 998'244'353, mod = 1'000'000'007, MX = INT64_MAX, MN = INT64_MIN, oo = 4e18;
#ifdef DEBUG
#include "./Debug/debug.hpp"
#else
#define debug(args...) 0;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
// using namespace __gnu_pbds;
using namespace std;
vec(string) tokenizer(string str,char ch) {std::istringstream var((str)); vec(string) v; string t; while(getline((var), t, (ch))) {v.pb(t);} return v;}
template<typename T> struct Comp { bool operator()(const T& l, const T& r) const { return l < r; } };
template<typename T1, typename T2> inline istream& operator >> (istream& in, pair<T1,T2>& a) { in>>a.first>>a.second; return in; }
template<typename T1, typename T2> inline ostream& operator << (ostream& out, pair<T1,T2> a) { out<<a.first<<" "<<a.second; return out; }
template<typename T> istream& operator >> (istream& in, vector<T>& v) { rep(i,1,sz(v)) cin>>v[i]; return in; }
template<typename T,typename T1> inline bool amax(T &a,T1 b){ if(b>a) { a=b; return true; } return false; }
template<typename T,typename T1> inline bool amin(T &a,T1 b){ if(b<a) { a=b; return true; } return false; }
void read(auto&... args) { ((cin>>args), ...); }
void put(auto&&... args) { ((cout<<args<<" "), ...);}
void file_i_o()
{
freopen("./tests/test01.txt", "r", stdin);
freopen("./tests/output01.txt", "w", stdout);
}
// If you win, you live. You cannot win unless you fight.
void TATAKAE(int T)
{
get(int,L,R)
function<vector<pii>(int,int)> helper = [&](int l, int r) -> vector<pii> {
if(l==r) return {};
for(int bit=__lg(LSB(l)); bit>=0; bit--){
if(r >= (1LL<<bit)*((l>>bit)+1)){
auto rest = helper((1LL<<bit)*((l>>bit)+1),r);
rest.pb(l,(1LL<<bit)*((l>>bit)+1));
return rest;
}
}
auto rest = helper(l+1,r);
rest.pb(l,l+1);
return rest;
};
auto ans = helper(L,R);
reverse(all(ans));
putn(ans.size())
for(auto& [l,r]:ans) putn(l,r);
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//file_i_o();
int t=1;
rep(i,1,t+1)
{
//cout<<"Case #"<<i<<": ";
TATAKAE(i);
}
#ifndef ONLINE_JUDGE
cerr<<"\ntime taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
#endif
return 0;
}
Submission Info
| Submission Time |
|
| Task |
D - Divide Interval |
| User |
Scythe |
| Language |
C++ 20 (gcc 12.2) |
| Score |
450 |
| Code Size |
4886 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3636 KiB |
Compile Error
Main.cpp: In function ‘void TATAKAE(long long int)’:
Main.cpp:76:18: warning: unused parameter ‘T’ [-Wunused-parameter]
76 | void TATAKAE(int T)
| ^
Main.cpp: In function ‘void file_i_o()’:
Main.cpp:71:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
71 | freopen("./tests/test01.txt", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:72:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
72 | freopen("./tests/output01.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
450 / 450 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_01.txt |
AC |
1 ms |
3492 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3496 KiB |
| 00_sample_03.txt |
AC |
1 ms |
3492 KiB |
| 01_test_01.txt |
AC |
1 ms |
3352 KiB |
| 01_test_02.txt |
AC |
1 ms |
3568 KiB |
| 01_test_03.txt |
AC |
1 ms |
3420 KiB |
| 01_test_04.txt |
AC |
1 ms |
3364 KiB |
| 01_test_05.txt |
AC |
1 ms |
3496 KiB |
| 01_test_06.txt |
AC |
1 ms |
3444 KiB |
| 01_test_07.txt |
AC |
1 ms |
3504 KiB |
| 01_test_08.txt |
AC |
1 ms |
3504 KiB |
| 01_test_09.txt |
AC |
1 ms |
3428 KiB |
| 01_test_10.txt |
AC |
1 ms |
3636 KiB |
| 01_test_11.txt |
AC |
1 ms |
3512 KiB |
| 01_test_12.txt |
AC |
1 ms |
3424 KiB |
| 01_test_13.txt |
AC |
1 ms |
3632 KiB |
| 01_test_14.txt |
AC |
1 ms |
3508 KiB |
| 01_test_15.txt |
AC |
1 ms |
3496 KiB |
| 01_test_16.txt |
AC |
1 ms |
3444 KiB |
| 01_test_17.txt |
AC |
1 ms |
3440 KiB |
| 01_test_18.txt |
AC |
1 ms |
3420 KiB |
| 01_test_19.txt |
AC |
1 ms |
3468 KiB |
| 01_test_20.txt |
AC |
1 ms |
3496 KiB |
| 01_test_21.txt |
AC |
1 ms |
3432 KiB |
| 01_test_22.txt |
AC |
1 ms |
3448 KiB |
| 01_test_23.txt |
AC |
1 ms |
3428 KiB |
| 01_test_24.txt |
AC |
1 ms |
3440 KiB |
| 01_test_25.txt |
AC |
1 ms |
3484 KiB |
| 01_test_26.txt |
AC |
1 ms |
3412 KiB |
| 01_test_27.txt |
AC |
1 ms |
3424 KiB |
| 01_test_28.txt |
AC |
1 ms |
3484 KiB |
| 01_test_29.txt |
AC |
1 ms |
3424 KiB |