akshayarise's blog

By akshayarise, history, 6 years ago, In English

Here is my code which is got accepted in GNU G++17 7.3.0 compiler but I am not able to find out why this is showing time limit error in GNU C++17 Diagnostics (Dr Memory) compiler.

A. New Building for SIS

include <bits/stdc++.h>

using namespace std; int main(){ register int n,h,low,high,k; ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

cin>>n>>h>>low>>high>>k;

register int ta,fa,tb,fb;

while(k--){

 cin>>ta>>fa>>tb>>fb;

 if(ta == tb)  
   cout<<abs(fa - fb)<<"\n";
 else if(fa < low && fb < low )
   cout<<abs(ta-tb) + low - fa + low - fb<<"\n";
 else if(fa > high && fb > high )
   cout<<abs(ta-tb) + fa - high + fb - high<<"\n";   
 else
   cout<<abs(ta-tb) + abs(fa-fb)<<"\n";

}

return 0; }

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

| Write comment?
»
6 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Dr Memory adds more code to check for various issues, thus slowing it down. Use this to debug your code and other compilers to actually submit.