Diagnostics detected issues [cpp.g++17-drmemory]

102 Views Asked by At

I've wrote the following code:

#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    map < char , long long > m ;
    long long counti = 1 , n , k , temp , pos , t , maxi ;
    for ( char c = 'a' ; c <= 'z' ; c++ ) { m[c] = counti ; counti++ ; }
    for ( char c = 'A' ; c <= 'Z' ; c++ ) { m[c] = counti ; counti++ ; }
    scanf ( "%lld" , &t ) ;
    while ( t-- ){
        temp = 0 ;
        maxi = 0 ;
        pos = 0 ;
        scanf ( "%lld%lld" , &n , &k ) ;
        string alpha ; 
        cin >> alpha ;
        for ( long long i = 0 ; i < min ( n , ( 2 * k ) + 1 )  ; i++ ){
            temp += m [ alpha [ i ] ] ;
            if ( i == 2 * k  ) { maxi = temp ; pos = k ; }  
        }
        if ( maxi == 0 && pos == 0 ) { pos = n - 1 ; maxi = temp ; }
        else for ( long long i = k + 1 ; i <= n - k - 1 ; i++ ){
                temp -= m [ alpha [ i - k - 1 ] ] ;
                temp += m [ alpha [ i + k ] ] ;
                if ( temp > maxi ) { maxi = temp ; pos = i ; }  
        }
        printf ("%lld %lld\n" , pos + 1 , maxi ) ;
    }
    return 0;
}

And I'm getting the following error after submitting it in codeforces.com :

Diagnostics detected issues [cpp.g++17-drmemory]: ~~Dr.M~~ Dr. Memory version 1.11.0
~~Dr.M~~ Running "program.exe"

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
~~Dr.M~~ 
~~Dr.M~~ Error #1: POSSIBLE LEAK 60 direct bytes 0x114200f8-0x11420134 + 0 indirect bytes
~~Dr.M~~ # 0 replace_malloc                    [d:\drmemory_package\common\alloc_replace.c:2576]
~~Dr.M~~ # 1 msvcrt.dll!strcpy_s              +0x5e     (0x75aef5d3 <msvcrt.dll+0xf5d3>)
~~Dr.M~~ # 2 msvcrt.dll!clearerr_s            +0x337    (0x75af9eed <msvcrt.dll+0x19eed>)
~~Dr.M~~ # 3 msvcrt.dll!clearerr_s            +0x27e    (0x75af9e34 <msvcrt.dll+0x19e34>)
~~Dr.M~~ # 4 pre_cpp_init
~~Dr.M~~ # 5 __tmainCRTStartup
~~Dr.M~~ # 6 KERNEL32.dll!BaseThreadInitThunk +0x11     (0x7582343d <KERNEL32.dll+0x1343d>)

Any idea would be much appreciated. Note that the code is running just fine on my computer.

0

There are 0 best solutions below