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

Автор kvtoraman, 14 лет назад, По-английски

In this submisson: 2431151 In that line: "if(hour[i]==hour[i-1]&&min[i]==min[i-1]){"

In the beginning, i=0 so that hour[i-1] means hour[-1].Can someone please explain how can this pass the pretests?

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

»
14 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

what can i do?

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

Well I try run this code

#include <iostream>
using namespace std;
int main() {
    int arr[100];
    cout << arr[-1] << endl;
    return 0;
}

on Costum Test in codeforces. It return 0 and did not give runtime error. I don't know what they use when compiling, but maybe this can explain why that code pass the pretest

UPDT I mean it produce output 0 and did not give runtime error

»
14 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

In C++, a[i] means *(a+i). This code accesses the memory cell located 4 bytes before than hour[0].