Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

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

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

This is a code from magician_man of 1455A - Strange Functions 100022199.

Notice that he used input[50] but not input[101].

I tried hack it but it did not get a RT.

How did it work?

#include<iostream>
#include<string>
#include<bits/stdc++.h>

using namespace std;

int main()
{
    int t,i;
    char input[50];
    cin >> t;
    for(i=1;i<=t;i++){
        cin >> input;
        cout << strlen(input) << endl;
    }
    return 0;
}
  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится

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

I tried to hack it too and its quite strange that RT comes after the test is run. I guess it might have something to do with the unallocated empty memory following the allocated one for this string.