I tried everything suggested in the discussion. Each test works, but when I submit, I get WA2. Can you please add more tests? Strange ... and now I got AC without any change to the logic. Just made each char taken from getchar() processed immediately instead of filling an array and then processing the array. Both versions work equally well on my computer. I use VS 2022. And one more thing - absolutely the same way of reading the input and filling the array I initially had a WA2 with, worked perfectly for problem 1601. AntiCAPS. (Actually that's where I copied the functionality from before I start). I guess Admins should take a look at this. Edited by author 17.12.2022 02:22 Where is my mistake? I have WA on test 2!!! #include <iostream> using namespace std; int main () { char c; int i,n,br=0,b=0,l=1; while (cin>>c) { if (c=='!'||c=='?'||c=='.') l=1; else { if (c>='a'&&c<='z') if (l==1) br++; if (c>='A'&&c<='Z') if (l==0) br++; l=0; } if (c=='!'||c=='?'||c=='.') { if (br>0) b+=1; br=0; } } cout<<b<<endl; return 0; } u cout "b"= 1 Edited by author 15.02.2022 18:32 Edited by author 15.02.2022 18:32 there are 2 details which are not mentioned in the document. 1. number(0-9) is also the splitor of word, so word can only contained characters,a-z. such as A0B is 2 words. 2. Next line starts one new word, but not always starts one new sentence, such as this is one sentence, but is splited to 2 lines. WA#3: new word start after '\n';(e.g. Abc'\n'new_word_here) WA#10 new word start after number; (e.g. 909090new_word_here) Thank you very much! It helps me a lot! I WA#3 because of this :D Thank you very much! It helps me a lot! I WA#3 because of this :D Thank you very much! It helps me a lot! I WA#3 because of this :D please give the code to java please give the code to java I had WA#3 because of how I was reading the input in C: while (gets(buff) != NULL) { int i = 0; while (buff[i] != '\0') { // process char by char i++; } } Changed to: while ((c = getchar()) != EOF) { // process char by char } And it works AC!!! Please help me with WA#10. Can you give me the test in which my program outputs this WA. program Project1; {$LONGSTRINGS ON} {$APPTYPE CONSOLE} uses SysUtils; var c,lc:char; ans:longint; b:boolean; begin {$IFNDEF ONLINE_JUDGE} reset(input,'input.txt'); rewrite(output,'output.txt'); {$ENDIF} ans := 0; b := false; c := #1; while not eof(input) do begin lc := c; read(c); if (c in ['a'..'z']) and (not b) then inc(ans); if (c in ['A'..'Z']) and (lc in (['A'..'Z'] + ['a'..'z'])) then inc(ans); if not (c in ['.','?','!',' ',#10,#13]) then b := true; if c in ['.','?','!'] then b := false; end; write(ans); end. -a. Answer is 1, but your program gives 0. My program give rigth answer for test : input: -a. output: 1 WHY I HAVE WA10????????!!!!!!!!!!!!!!! if you failed on test 10,try the follwing data or see the item Posted by Alam Md Mahabub September 27, 2001 14:23 ****************************************** Re: Can you give any judge data for which this code gives WA. Posted by SHMAK November 05, 2007 05:17 /*************************************** strange... but there are 5 mistakes: The old va[R]sag my Antonesgh..%[s]g4mahng 35tsavx 3mnkxb o o oo A[A] gfsd . [s]dgw a a[A] Aa ********************************* the weild part is that the last sentence doesnot contain a full stop, a question-mark or an exclamation mark
for me WA10 got away after i added check for digits in my condition to start new word. e.g. "A0B" have 0 errors My program (with error, I know where it is, but I will not write about it): import sys text = sys.stdin.readlines() text = ''.join(text) for symbol in ',;:-\n': text = text.replace(symbol, ' ') text = text.replace('!', '.').replace('?', '.') import re text = ' '.join(text.split()) text = text.replace('. ', '.') text = '.'.join(text.split('.')) text = text.replace(' .', '.') count = 0 for sentence in text.split('.'): if sentence != '': if sentence[0].islower(): count += 1 for word in sentence.split(): for letter in word[1:]: if letter.isupper(): count += 1 print(count) Edited by author 06.07.2016 19:17 What is in test 2 ?????????????????? YOUR TEST CASES ARE WROUNG MY PROGRAMM IS CORRECT !! my code: #include <iostream> #include <string> using namespace std; int main(int argc, char *argv[]) { string sent; char c = 0; size_t count = 0; while (cin.get(c)) { sent.push_back(c); if (c == '.' || c == '?' || c == '!') { size_t i = 0; while (i < sent.size() && !isalpha(sent[i])) { i++; } if (i < sent.size() && islower(sent[i])) count++;
string word = ""; for (size_t i = 0; i < sent.size() + 1; i++) { if (i < sent.size() && (isalpha(sent[i]))) { word += sent[i]; } else { for (size_t j = 1; j < word.size(); j++) { if (isupper(word[j]) && isalpha(word[j])) count++; } word = ""; } } sent.clear(); //cout << count << endl; } } cout << count; return 0; } Edited by author 12.06.2015 20:13 Edited by author 12.06.2015 20:13 for WA5, try this test hEllo wOrld!!! w The correct answer is 4 why answer is 4 ???? i think 5 would be correct one it maybe happen the end of file not end by : '!' || '?' || '.', like "this sentensec has no mistake" this sentences ,really has no mistake sorry, for my bad english :D Edited by author 08.10.2010 16:59 Edited by author 08.10.2010 16:59 Thank you! +1 Your sentence has mistake :) First letter in sentence should be capital. A a ans = 0 --------------------- A A ans = 0 --------------------- aB ans = 2 --------------------- asasa.!sds sdsdsd!!!..::dsd ans = 3 --------------------- -a. ans = 1 -------------------- 090aA is a number. ans = 2 -------------------- this sentence have one mistake ans = 1 -------------------- Hello! 238 my Friend ans = 1 -------------------- Asf,.,a ans = 1 -------------------- New tests have been added to this problem. Solutions have been rejudged. 564 authors have lost AC. Why WA#10? Me too WA#10 I got it! Look at this sentence. "090a is a number." a should be captilized,hope this note can help And one more: Input: 090aA is a number. Ouput: 2 #include<iostream> #include<fstream> #include<stdlib.h> #include<stdio.h> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("input.txt","rt",stdin); freopen("output.txt","wt",stdout); #endif char a[10005]={'\0'}; int i=0,n=0,g=0,n1,n2; bool f=true,ff=false; char ab[100]={'\0'}; int tt=scanf("%s",a); while(tt>0) { strcat(a,ab); strcat(a," "); tt=scanf("%s",ab); } n=strlen(a)-1; for(i=0;i<n;i++) { if (32<=int(a[i])&&int(a[i])<=64||91<=int(a[i])&&int(a[i])<=96||123<=int(a[i])&&int(a[i])<=255) if (a[i]!='.'&&a[i]!='!'&&a[i]!='?') {continue;} {continue;} if (a[i]=='.'||a[i]=='?'||a[i]=='!') {f=true; continue;} if (f&&'a'<=a[i]&&a[i]<='z') {g++; } f=false; } int k=0; n2=0; for(i=0;i<=n;i++) { [i]=='.'||a[i]=='!'||a[i]=='?'||a[i]=='%') if (32<=int(a[i])&&int(a[i])<=64||91<=int(a[i])&&int(a[i])<=96||123<=int(a[i])&&int(a[i])<=255) { n1=n2; n2=i; for(int j=n1+1+k; j<n2; j++) if ('A'<=a[j]&&a[j]<='Z') g++; k=1; } } cout<<g<<endl; return 0; } What it is WA #2; please, give me any test Hi, When you read the input, don't just concatenate all into one string. For example:- If the input is asasa.!sds sdsdsd!!!..::dsd Then, you should have a final string which is like this:- asasa.!sds sdsdsd!!!..::dsd and not like this asasa.!sdssdsdsd!!!..::dsd (this is wrong and will screw up) There should be a space between the two lines which you are reading and concatenating ! Well, I've got another stupid mistake with WA#3, you could detect it with test "aB" (answer is 2). Btw, in this problem one might consider reading a whole input at once. In C/C++ such reading might look like below: > FILE *source = stdin; > fseek(source, 0, SEEK_END); > long textLength = ftell(source); > rewind(source); > char* text = (char*)malloc(sizeof(char)*textLength); > fread(text,1,textLength,source); Try test "this sentence have one mistake" Answer is 1 |
|