Please read the new rule regarding the restriction on the use of AI tools. ×

Gwazy's blog

By Gwazy, history, 4 years ago, In English

29A - Spit Problem

#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
 
int main() {
    IOS
 
    int n;
    cin >> n;
    int x[n], d[n];
    x[0] = 0;
    d[0] = 0;
 
    for(int i = 0; i < n; i++){ 
        scanf("%d", &x[i]);
        scanf("%d", &d[i]);
    }
    
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if ((x[i] + d[i]) == x[j]) {
                if(x[j] + d[j] == x[i]) {
                    cout << "YES";
                    return 0;
                }
            }
        }
    }
    cout << "NO";
    return 0; 
}

Hey Code Forcers, I'm running this code on my terminal, and I'm getting a correct output for all tests.

However, when I submit the code to CodeForces, I fail test case two.

Initially, I was getting an uninitialized value usage before I initialised arrays x and d, could it be related?

I would appreciate any help,

Thanks

Full text and comments »

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