oh, i got AC. If anybody want to know - yes, he can! I got WA on test #5 can you tell me why? This test case helped me. 6 1 2 2 4 4 5 5 6 BLOOD 3 5 Answer: 0 Why answer is not a 1 2 4? Edited by author 13.04.2019 11:10 I have ans = 0 but although it giving WA on test #5 can you suggest me some error or another test case Please remember that input can contain numbers with more than one digit. My WA was due to this, and I don't think anybody will be this silly. But still posting! :) Edited by author 29.08.2022 21:23 Edited by author 29.08.2022 21:23 Have no idea what's wrong I used simple plan with massive of relations and recursive function that checks all ancesters (only up moving) and all descendants (only down moving). There is some part of code in C++: int checkforblood(int index, int** mas, int* checkmas, int range, int direct) { if (checkmas[index - 1] == 1) return 0; checkmas[index-1] = 1; for (int i = 0; i < range; i++) { if (( mas[i][0] == index )&&(direct > -1)) { checkforblood(mas[i][1], mas, checkmas, range, 1); } if (( mas[i][1] == index ) && (direct < 1)) { checkforblood(mas[i][0], mas, checkmas, range, -1); } } return 0; } I can't see the problem, so if you can't too i will know, that problem in output method. Edited by author 31.05.2022 02:26 I tried all test cases which were written in the discussion part and my program gives the correct answer for all of them. How to find my error: #include <bits/stdc++.h> using namespace std; #define pb push_back #define endl "\n" /*DELETE IT ON INTERACTIVES!!*/ #define mod 1000000007 #define int long long #define double long double #define all(x) x.begin(), x.end() const int N = 1e3+5; vector<int> adj[N],marked(N,0),killed(N,0),vis_1(N,0),torun(N,1),vis_2(N,0); int ok; void dfs(int node){ vis_1[node] = 1; if(killed[node]) ok = 1; for(auto go : adj[node]){ if(!vis_1[go]){ dfs(go); } } } void mark(int node){ marked[node] = 1; vis_2[node] = 1; for(auto go : adj[node]){ if(!vis_2[go]){ mark(go); } } } void solve(){
int n; cin>>n; string s,t; while(cin>>s){ if(s == "BLOOD") break; cin>>t; adj[(int)s[0] - '0'].pb((int)t[0] - '0'); torun[(int)t[0] - '0'] = 0; } int a; while(cin>>a){ killed[a] = 1; } for(int i=1;i<=n;i++){ if(torun[i]){ dfs(i); if(ok){ mark(i); } fill(all(vis_1),0); fill(all(vis_2),0); ok = 0; } } int hehe = 0; for(int i=1;i<=n;i++){ if(!marked[i]){ hehe = 1; cout<<i<<' '; } } if(!hehe) cout<<0; } int32_t main(){
cin.tie(0); ios::sync_with_stdio(0); int t=1; //cin>>t;
while(t--) solve();
return 0; } To enter variables correctly is more difficult then solve this problem. I think, it isn't very good idea to issue input like this. I got WA on test 4, but on all tests I could make myself and also on those, which were in the problem, my program answered correctly. Please, suggest some tests, that could help. I need you help. What could be the #5 test like? I lengthen my array so as to avoid the RE... this test can help you: 9 4 1 2 4 3 4 6 4 5 4 7 5 8 5 9 7 BLOOD 5 answer is: 2 3 6 Good luck! My answer to this test is right,but i also get wa! why? Edited by author 18.10.2012 18:48 My answer is right but WA 5 ... I got runtime error at test 5. Can anybody send me the fifth test of this problem? My program always crushes on it. I think it's something wrong when input my data int size; struct point{ int number; bool pr; }; vector<point> matrix[1000]; int main(){ int name1, name2; point c; char hg='0'; vector<int> victims; cin >> size; while (hg != 'B'){ cin >> hg; if (hg != 'B'){ cin >> name2; name1 = atoi(&hg); c.pr = true; c.number = name2 - 1; matrix[name1 - 1].push_back(c); c.pr = false; c.number = name1 - 1; matrix[name2 - 1].push_back(c); } } for (int i = 0; i < 4; i++) cin >> hg; while (std::cin >> name1) victims.push_back(name1 - 1); int victim; while (scanf("%d", &victim) != EOF) { /*do something*/ } it is an infinite loop scanf returns: number of the read charecter in finish scanf return 0 but EOF value is -1 WereWolf can eat his sister or brother. But He cannot eat his father and mother, also grandfather ... so on....grandmother... I think this problem can be solved easily by using DFS algo. But there's sth I wantwd to ask. if our program is reading from the standard input, Can we use eof(f) in paskal? what should we do then? is it OK to use ASSIGN procedure for a file which has been made beore? I think it takes CRASH(ACCES VIOLATION) error. Is there anyone who can help me on the spot?!! I had the same problem, because I read char and if it was 'B', I go to next stage. It was always OK except this case: 100 BLOOD 1 2 I didn't eat the newline after 100, however I always did after numbers that went after it. Anyway - this is why test 4 is special. Hope that helps :-D I write a programm, but got WA. I think my program is right, but I can't check it! Please if you can, give me some tests. Thank you Try this 24 6 4 21 3 7 4 16 19 8 4 3 2 22 3 23 3 4 2 13 12 13 11 5 1 2 1 5 10 2 9 11 5 24 3 12 5 9 17 14 15 9 14 1 18 19 20 14 16 B L O OD 3 8 And the answer 5 6 7 10 11 12 13 Good luck Did you read this: "Posted by Tasman March 26, 2003 09:32"? Well, it can be useful for others ;-) Edited by author 12.12.2007 01:35 Edited by author 09.11.2008 17:03 Edited by author 09.11.2008 17:03 What was made with simple 1242! During a long time i had Wa2 but with the same code have AC now! It should be said about mistakes in tests for 1242 and their correcting. Sorry. We have fixed a bug in 2'nd test several days ago and haven't rejudged all wrong verdicts yet. Now they are rejudged. Your old submissions are AC. Does it mean that you rejudged test like ' 'number' 'number to number' 'number? There is a space in the end of second line of second test. Probably in testing system this space is lacking. Please, correct the test in task. From the input description I understood that the first number is the child and the second number is the father, but in the first sample child number 4 has 2 parents, 5 and 6. "The data is correct - for each of the residents there are no more than two parents, and there are no cycles." father and mother For test2 my program think that number of victims=0,or oboroten has no his actions What answer must be in this case 1) 1 2 ... N because have no information to conclusions; 2) 0 3) All people who have N-1 strict relations, But also wa2 This is plain crazy! My program uses STL vectors and recursive function calls and it sure adds an extra overhead to the overall memory, but... 18 MB? That's a novelty! Of course I get MLE. If someone experienced something like it before please let me know! P.S. On my PC it shows 1MB of allocated memory for N=1000. Strange,huh? Extra spaces were removed from the input. 26 authors got AC. Now you can use Pascal function val() for reading input data. |
|