|
|
Common Boarddont forgot about solo points Try this one 0 0 1 1 1 0 2 -1 Ans: 0 Try: 101 203 1000 Or: 1 3 1000 I think this test should break some AC solutions: 443 -39 457 33 386 -773 561 127 Correct answer is -1, but I think some AC solutions can print 0 read the tags before you decide, and think a few times before you start Test 47 is some number from 1e14 to 1e18 with correct answer "No". 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 |
|
|