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

Автор rohankag7, история, 8 лет назад, По-английски

For the problem — 1038D - Slime Here's my solution — 42603855 My solution runs in O(n) but still the time taken is 1341ms

But in another solution of a different person, for O(n) solution the time taken is 46ms- 42576776

Can somebody please tell me why is this happening?

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

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

in C++ using cin, cout is easier to use but slower than other streams.

to solve this problem there is two way:

1- use another streams like scanf, printf, ...

2- type this at the top of main:

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

it makes io faster but should only use of this streams (cin,cout) or (scanf,printf) because compiler want to sync this streams and it needs time, so with this code you don't sync them and you can only use one of them.

sorry for mu bad english !!