suraj021's blog

By suraj021, 5 years ago, In English,

I solved 380C - Sereja and Brackets using segment tree for logarithmic time complexity , but my my solution got TLE 11267626 for some test case . I want to ask if there is something wrong with my implementation or i have to use some other data structure ? P.S positive responses will be appreciated :)

UPD: Accepted: 11271890 :)

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

»
5 years ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it
void build( string str, int id, int l, int r ){

if you write it this way string str will be copied each time you call the build function, so total complexity is O(n^2).

You should change it to

void build( string& str, int id, int l, int r ){

P.S 11267959 Accepeted by changing only this char)

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks Got AC. But there is significant amount of memory used. Is it because of large strings and long queries or something else? Thanks a lot sir,

»
5 years ago, # |
  Vote: I like it -18 Vote: I do not like it

u are too noob

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    My graph shows that , doesn't it ? :)

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      no your handle shows it

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        You have nothing to do with this.Either answer the question which he asked or get lost.You Big mouth.