|
|
Общий форумwa5 - check how you calculate time when change direction at the station Test: 12 1 2 45 64 31 23 128 61 2 2 7 8 7 3 5 ans: 805 Test: 4 7 6 3 3 12 3 4 ans : 60 Good luck! Here's my wrong solution, can sb view the code and help me? #include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int> pos; vector<vector<int>> in; vector<vector<int>> out; vector<int> ans; void lets_go(int i) { for (int j = 0; j < in[i].size(); j++) { if (pos[in[i][j]] == 0) { lets_go(in[i][j]); } } pos[i] = 1; ans.push_back(i); for (int j = 0; j < out[i].size(); j++) { if (pos[out[i][j]] == 0) { lets_go(out[i][j]); } } } int main() { int n; cin >> n; in.resize(n); out.resize(n); pos.resize(n, 0); for (int i = 0; i < n; i++) { int a; cin >> a; while (a != 0) { if (a != 0) { in[a - 1].push_back(i); out[i].push_back(a - 1); cin >> a; } } } for (int i = 0; i < n; i++) { if (pos[i] == 0) { lets_go(i); } } for (int i = 0; i < n; i++) { cout << ans[i] + 1 << " "; } } my solution is the following: start with least common multiple = 1 make char array of 1000 000 to track forbidden divisors let div be the divisor and ans the answer if ans == 1 make new lcm of the previous lcm and current divisor. if it is over 10^12 - fail. find all the divisors of div, check that they are not forbidden in the forbidden array if ans == 0 - check if lcm is divisible by the divisor and fail if it is.
complexitiy O(n * sqrt(1000000)) (sqrt from the "find all divisors) my solution gets 0.5 sec (using cin,cout with tie(null)) what is the solution that gets less than 0.1 sec? Is there any hint? no need to find all divisors. u can just use lcm and mod operations. i can send you easy solution if u r still interested need to pray to god for quick solutions #pragma GCC optimize("Ofast") #pragma GCC optimize(O3) #pragma comment(linker, "/stack:200000000") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("profile-values,profile-reorder-functions,tracer") #pragma GCC optimize("vpt") #pragma GCC optimize("rename-registers") #pragma GCC optimize("move-loop-invariants") #pragma GCC optimize("unswitch-loops") #pragma GCC optimize("function-sections") #pragma GCC optimize("data-sections") #pragma GCC optimize("branch-target-load-optimize") #pragma GCC optimize("branch-target-load-optimize2") #pragma GCC optimize("btr-bb-exclusive") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") Try this test: 1 1 2 0 1 -1 0 1 Answer: 1 1 2 0 error in path recovery at a fixed level for 2 = 2 3 = 12 4 = 104 can u give some tests? Edited by author 21.10.2012 12:05 011 ans: 11 maybe forgot some reverse you forgot about something It is something wrong. Can somebody help me? I have completed this problem. Test #7 is single '('. Thank you VERYYYYYY MUUUCH! I solved this problem because of yoy =) :-) :=) thanks a lot. After this test I got accepted My program passed this test '('. And also my program passed all the testes I've found here... but result is still WA7. I don't know why. Can someone help me? I've got an AC! Probably, my mystake was in wrong work with carrage return symbols.. Thankkkkkkkkkkkkkkkkkk a llotttttttt Exactly! Thank you very much. For all other users experiencing test#7 WA: Test your program exactly with this data: (<EOF> Got AC now thanks for test :) Probably, test 7 is 'a(' Add some letter before '(' 5 7 3 4 1 2 2 1 2 4 3 1 3 5 5 5 5 4 Answer: 0 I have two different solutions which handle this test very differently: 20 5 24 0.0 - 1.0 0.1 - 1.0 0.2 - 1.1 0.3 - 1.2 0.4 - 1.3 0.5 - 1.4 0.6 - 1.5 0.7 - 1.6 0.8 - 1.7 0.9 - 1.8 0.10 - 1.9 0.11 - 1.10 0.12 - 1.11 0.13 - 1.12 0.14 - 1.13 0.15 - 1.14 0.16 - 1.15 0.17 - 1.16 0.18 - 1.17 0.18 - 2.0 0.18 - 3.0 0.18 - 4.0 0.18 - 5.0 0.19 - 1.18 0 19 One of them might be even close to TLE, but both my solutions accepted here with time 0.015 s, which makes me think there is no such test in the list of tests. I think this test should be added... Your test has been added. 1 author lost AC after rejudge. Thanks and feel free to send more tests to support email. I don't understand, why did the authors create such a question that gets AC only if solved with Python or Java. The problem was created back in the days when only available languages in the judge were Pascal, C and C++. "...Она сразу же позвонила своей начальнице, затем своей подруге Лене, находящейся у неё в подчинении, потом Кате и Маше...". In my solution she can call friends, and then her boss. And solution, when she at first call the boss and then friends, get WA4. Yeah, it sucks that the statement is not reliable. Added a hint to the statement. I don't understand what dp has to do with this problem. I solved it using string hashing. If you're curious, I mean hashing the row or the column. I didn't hash the both and it is AC. 2D hashing is not needed in this problem (I'm not sure if it exists). |
|
|