How can I solve Problem 275A ? http://codeforces.com/problemset/problem/275/A

# | User | Rating |
---|---|---|

1 | tourist | 3707 |

2 | Benq | 3672 |

3 | ksun48 | 3575 |

4 | Radewoosh | 3562 |

5 | Miracle03 | 3480 |

6 | maroonrk | 3406 |

7 | ecnerwala | 3400 |

8 | peehs_moorhsum | 3384 |

9 | sunset | 3338 |

10 | Um_nik | 3320 |

# | User | Contrib. |
---|---|---|

1 | 1-gon | 208 |

2 | YouKn0wWho | 204 |

3 | Um_nik | 197 |

4 | Errichto | 181 |

4 | sus | 181 |

6 | awoo | 179 |

7 | tourist | 175 |

8 | -is-this-fft- | 171 |

8 | SecondThread | 171 |

10 | Ashishgup | 170 |

How can I solve Problem 275A ? http://codeforces.com/problemset/problem/275/A

↑

↓

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/28/2021 21:10:46 (i1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

Consider a simpler problem:

Every time you press a light only the light pressed will be toggled.

Now it is obvious that if a light is pressed event number of times it will be in it's initial state (ON).

Now to solve the initial problem:

Let

`pressed[3][3]`

be the initial matrix and`toggled[3][3]`

the matrix of total lamp presses.In the beginning

`pressed[][] = toggled[][]`

.Now if

`pressed[i][j] != 0`

then we have to add`pressed[i][j]`

to`toggled[i][j + 1]`

,`toggled[i][j - 1]`

,`toggled[i - 1][j]`

and`toggled[i + 1][j]`

. Now we are left with the first, much simpler problem.But be careful when handling edge lamps.

My solution (see how I handle edge lamps): http://codeforces.com/contest/275/submission/20742578

I hope I helped you.

Here is the same idea, but with different implementation. well, just consider it as another reference, haha :)

275A

Hope this helps :)

Thanks a lot, Buddy!

why the array is declared as global ?is there any reason?

Here is my Solution : https://codeforces.com/contest/275/submission/126631294

nice ping bro

why everyone down-voted for my submission? is my approach is wrong?

You complicated the solution unnecessarily, that is why

And you necroed, that is why