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

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

1 | tourist | 3707 |

2 | Benq | 3672 |

3 | Radewoosh | 3627 |

4 | ksun48 | 3547 |

5 | Miracle03 | 3480 |

6 | ecnerwala | 3400 |

7 | peehs_moorhsum | 3384 |

8 | maroonrk | 3361 |

9 | sunset | 3338 |

10 | Um_nik | 3320 |

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

1 | 1-gon | 209 |

2 | Um_nik | 196 |

3 | YouKn0wWho | 192 |

4 | Errichto | 182 |

5 | awoo | 181 |

6 | sus | 180 |

7 | tourist | 175 |

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

9 | SecondThread | 170 |

9 | Radewoosh | 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/20/2021 08:04:58 (g1).

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