YouCantTouchThis54's blog

By YouCantTouchThis54, history, 5 weeks ago, In English,

Hey so I was working on a problem recently and when I tested in custom invocation it worked.

When i submitted it didnt work?

Why would this happen?

Submission: 86015133 Problem: 344A - Магниты

Output On the single line of the output print the number of groups of magnets.

Code: ~~~~~ from sys import stdin, stdout def main(): n = int(stdin.readline()) l = 0 y = " " for x in range(0,n): y = stdin.readline() x = stdin.readline() if(x != y): l = l + 1 stdout.write(str(l+1)) main() ~~~~~

Image 1 Image 2

Please help, I have no idea what I'm doing wrong :(

 
 
 
 
  • Vote: I like it
  • +8
  • Vote: I do not like it

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by YouCantTouchThis54 (previous revision, new revision, compare).

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by YouCantTouchThis54 (previous revision, new revision, compare).

»
5 weeks ago, # |
  Vote: I like it +13 Vote: I do not like it

Aren't you trying to read $$$2n$$$ lines of input when there are only $$$n$$$?

If you run on custom invocation with an extra newline after the first sample's input, you'll end up with the same output as the submission.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by YouCantTouchThis54 (previous revision, new revision, compare).