AshToady's blog

By AshToady, history, 11 days ago, In English

here's my code to the most annoying problem i've ever encountered(its a recent one, so you probably know it),

i'm getting 2147483647 runtime error.

Having submitted over 15/20 codes over a period of a week, and researching on it, i'm sure my algorithm is correct, have checked it innumerable times.

To simplify the logic-> its grouping numbers with matching largest bits and feeding it to calc function for further recursion till required.

what is this error 2147483647? i've faced it many times, but never really understood it, it always magically somehow gets resolved, except this time.

need help!

and if you can spot the mistake, kindly let me know.

Read more »

  • Vote: I like it
  • -20
  • Vote: I do not like it

By AshToady, history, 3 weeks ago, In English

Considering everything i could find on maps, unordered maps are supposed to be faster than maps. I experimented on a cses problem, and surprisingly unordered map gave TLE on a few test cases whereas map passed them all.



#define ll long long
#define fi first
#define se second
using namespace std;
#define int long long
int n,x;cin>>n>>x;int a[n+1];

 for(int i=1;i<=n;cin>>a[i++]);
  for(int i=1;i<=n;i++)
  int cnt=0;

  for(int i=n;i>0;i--)
  {  mp[a[i]]--;


Read more »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By AshToady, history, 3 months ago, In English

solution with settings=c++14 solution with settings=c++17 I have never used gnu c++17 as my setting, always c++14. But what actually happened was, in my ide, visual studio, test case-2 gave correct output=13...but on codeforces results of the test was showing output=11 wrong ans. i thought this is some codeforces glitch, i changed the code variables a bit to be able to submit the same code again. But nothing changed. Then i randomly thought of changing lang to c++ 17...and it gave all correct outputs->accepted i.e.

I dont what i should do...its been an year, never used c++17 settings... why did this happen today?

Read more »

  • Vote: I like it
  • -15
  • Vote: I do not like it