Educational Codeforces Round 140 Editorial
source link: https://codeforces.com/blog/entry/110225
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Educational Codeforces Round 140 Editorial
19 hours ago, # | I have become an Expert thanks to this contest! Great D by the way. |
In problem A, since the first line is empty. I read it as a string and never bothered to use it. It WA'd. This is my submission 185477892 . After the contest, I didn't even bother to read the first line and used the same code as above and it got AC. I am not sure why and could use some help.185647398 |
-
cin >> [whatever]
doesn't work as you think. The input data is split into tokens: a token is a sequence of characters. Tokens are separated by whitespaces (incl. normal spaces and newline characters). Doingcin >> [whatever]
reads the next token* and tries to convert it into the type of the variable. Doingcin >> [whatever]
always skips over any spaces and newline characters. Thus, yourcin >> s
reads the first integer into your string, messing up the values. In order to read a full line into a single string (including all spsces, but not the newline character) you need to do the following:string s; getline(cin, s);
*doing
cin >> [char]
only reads the next character, but it still skips whitespaces.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK