Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Asterisk007

Автор Asterisk007, история, 2 года назад, По-английски

Since I cant find the editorial i am asking my doubt here. my code to problem F

https://codeforces.net/contest/1729/problem/F

is repeatedly failing test case 7.

Here is my code for your reference:

https://codeforces.net/contest/1729/submission/172019259

thanks

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
2 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

you are trying to cast string to int with stoi() but the result is too large to represent it as integer. My local G++ 12.2.0 fails with std::out_of_range if i want to cast string '111...1' (length = 1000) to int with stoi() for example

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

string qq=s.substr(l-1,r-l+1); int j=stoi(qq);//here it is exceeding integer limit...

notice that you don't need to store the whole number in 'j' variable ...just store gg%9 in 'j'

but still it will give TLE you need to process all 'w' substrings and store the information in an double dimentional vector and later in queries you can use them in O(1) time :-)