Общий форумi think my algo is right but i have problem with overflow in C++. who can give me good test? PS: on Pypy i have TL50 using the same algo( And it's very strange because on test 1000000000 18 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 my algo works <300ms PS: AC in C++ after many hacking with overflow. I hate this problem because spent a lot of time to fix problem with arighmetic (not algo) Edited by author 12.12.2023 00:41 It seems that the worm always starts at back cover and ends at front cover and order of volumes matters. #include <iostream> using namespace std; int main() { double k; while(cin >> k) { cout << fixed << setprecision(4) << sqrt(k) << endl; } } I think the solution is supposed to start from the last number Подскажите, что нужно сделать чтобы у меня показывало на каком я месте в рейтинге? Просто интересно, уже год-два моя страничка вне рейтинга this is a not correct setting task, there are many solutions some of them is AC some of WA, but all of them are right for N this is a right solution count is 2*(N - 2) and 2 2 3 3 4 4 .... (N-1) (N-1) isn't it 1 10 1 2 -> 2: means books are placed upside down, in this case first sheet of the first book is adjacent to the second book 1 10 2 1 -> 22: means books are placed correctly, last sheet of the first book is adjacent to the second book Edited by author 10.11.2015 07:42 Try this test 1 100 4 1 1 2 1 3 1 4 1 1 2 3 4 0 0 0 1 5 1 Correct answer is: 3.0200000 4 1 2 3 4 #include<bits/stdc++.h> using namespace std; bool isPrime(int n) { if(n!=2&&n%2==0)return false; if(n<2)return false; for(int i=3;i<=sqrt(n);i+=2) { if(n%i==0)return false; } return true; } int main() { int n; cin>>n; int x=9,r; if(n==1)cout<<1<<endl; else if(n==0)cout<<10<<endl; else{ vector<int>v; while(1) { if(n%x==0) { if(isPrime(n)==true) { if(n>9){cout<<-1<<endl;return 0;} } n=n/x; if(x==1)break; v.push_back(x); } else { x--; } } for(int i=v.size()-1;i>=0;i--) { cout<<v[i]; } cout<<endl; } } For large N, 2% of sample are counted. Thx a lot for every man and women for tests. Try this: 4 4 1111 1110 1100 1000 The answer: 1110 1101 1011 0111 My code gives right answer for this test, but still got WA8. My algo: 1) find any perfect match (I use kuhn algorithm). If there no perfect match print unary matrix and quit. 2) for every i-monster, remove edge (i, match(i)), and try make alternate path for i. save result in d[] array, and restore edge (i, match(i)) . 3) We can select (i,j) edge only if Mij = true AND (i,j) edge in perfect match, or j is free vertex, or d[ match( j ) ] is true. Can give some tests ? Test: 6 7 1111000 1110000 1100000 1000100 0000110 0000110 WA8 answer: 0000111 0001111 0011111 0111011 1111001 1111001 const int MaxLength = 30; const int Lines = 8; const int MaxStation = 15; const int Stations[Lines] = {13, 10, 11, 12, 9, 14, 15, 13}; const char Line[Lines][MaxStation][MaxLength + 1] = { {"7_klyuchey", "Sortirovochnaya", "China_town", "Zarechny", "City", "1905_year_square", "Kuybyshevskaya", "Sibirskaya", "Siniye_kamni", "Lechebnaya", "Varshavskaya", "Kompressornaya", "Koltsovo"}, {"Zelyony_ostrov", "Tatishchevskaya", "Verh_Isetskaya", "Kommunarov_square", "1905_year_square", "Teatralnaya", "Vostochnaya", "Vtuzgorodok", "Kamennye_palatki", "University"}, {"MEGA", "Metallurgov", "Kraulya", "Central_stadium", "Moskovskaya", "1905_year_square", "Shevchenko", "Pionerskaya", "Turbinnaya", "Elmash", "Taganskaya"}, {"Akademicheskaya", "Yugo_zapadnaya", "Volgogradskaya", "Posadskaya", "Geologicheskaya", "Teatralnaya", "Gagarinskaya", "Komsomolskaya", "Shefskaya", "Ozyornaya", "Italyanskaya", "Kalinovskaya"}, {"Sovhoznaya", "Voennaya", "Aviatsionnaya", "Dvorets_sporta", "Geologicheskaya", "Kuybyshevskaya", "Vostochnaya", "Gagarinskaya", "Vilonovskaya"}, {"Keramicheskaya", "Vtorchermet", "Samolyotnaya", "Botanicheskaya", "Parkovaya", "Mayakovskaya", "Oborony_square", "Kuybyshevskaya", "Teatralnaya", "Shevchenko", "Uralskaya", "Zvezda", "I_Pyatiletki_square", "Pobedy"}, {"Himmash", "Nizhne_Isetskaya", "Uktusskie_Gory", "Shcherbakovskaya", "Botanicheskaya", "Chkalovskaya", "Bazhovskaya", "Geologicheskaya", "1905_year_square", "Dinamo", "Uralskaya", "Mashinostroiteley", "Uralmash", "Prospekt_Kosmonavtov", "Bakinskih_Komissarov"}, {"Moskovskaya", "Kommunarov_square", "City", "Uralskaya", "Pionerskaya", "Gagarinskaya", "Vtuzgorodok", "Sibirskaya", "Oborony_square", "Bazhovskaya", "Dvorets_sporta", "Posadskaya", "Moskovskaya"} }; Thank you! You save my time. 1024 lz good man Thanks! :) Reformatted for C++ vector<vector<string>> a { {"7_klyuchey", "Sortirovochnaya", "China_town", "Zarechny", "City", "1905_year_square", "Kuybyshevskaya", "Sibirskaya", "Siniye_kamni", "Lechebnaya", "Varshavskaya", "Kompressornaya", "Koltsovo"}, {"Zelyony_ostrov", "Tatishchevskaya", "Verh_Isetskaya", "Kommunarov_square", "1905_year_square", "Teatralnaya", "Vostochnaya", "Vtuzgorodok", "Kamennye_palatki", "University"}, {"MEGA", "Metallurgov", "Kraulya", "Central_stadium", "Moskovskaya", "1905_year_square", "Shevchenko", "Pionerskaya", "Turbinnaya", "Elmash", "Taganskaya"}, {"Akademicheskaya", "Yugo_zapadnaya", "Volgogradskaya", "Posadskaya", "Geologicheskaya", "Teatralnaya", "Gagarinskaya", "Komsomolskaya", "Shefskaya", "Ozyornaya", "Italyanskaya", "Kalinovskaya"}, {"Sovhoznaya", "Voennaya", "Aviatsionnaya", "Dvorets_sporta", "Geologicheskaya", "Kuybyshevskaya", "Vostochnaya", "Gagarinskaya", "Vilonovskaya"}, {"Keramicheskaya", "Vtorchermet", "Samolyotnaya", "Botanicheskaya", "Parkovaya", "Mayakovskaya", "Oborony_square", "Kuybyshevskaya", "Teatralnaya", "Shevchenko", "Uralskaya", "Zvezda", "I_Pyatiletki_square", "Pobedy"}, {"Himmash", "Nizhne_Isetskaya", "Uktusskie_Gory", "Shcherbakovskaya", "Botanicheskaya", "Chkalovskaya", "Bazhovskaya", "Geologicheskaya", "1905_year_square", "Dinamo", "Uralskaya", "Mashinostroiteley", "Uralmash", "Prospekt_Kosmonavtov", "Bakinskih_Komissarov"}, {"Moskovskaya", "Kommunarov_square", "City", "Uralskaya", "Pionerskaya", "Gagarinskaya", "Vtuzgorodok", "Sibirskaya", "Oborony_square", "Bazhovskaya", "Dvorets_sporta", "Posadskaya", "Moskovskaya"} }; Check how you restore the answer. I had the right price , but it brought out fewer dishes than necessary Can anyone say, what is wrong in my solution? public class T1779 { public static void main(String[] args) throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out=new PrintWriter(System.out); int n=Integer.parseInt(in.readLine()); int sum=0; for(int i=0; i<n/2; i++){ for(int j=n-i-1; j<n; j++){ if(i!=j){ out.println((i+1)+" "+(j+1)); sum++; } } } System.out.println(sum); out.close(); } } Repalce the conditions i != j with i < j because you print some edges twice. Sorry for my bad English Very good opportunity to apply Gosper's hack trick. m is number of different colors in the input. Then iterate through all subsets of size k of m. It's really works. But I don't understand why this algo work. Can you explain me? I was getting wa6 because the salary[0] not equal to 0 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 What data it is? I didn't check that p[9] == 10 when p[8] == 10, where p[1]...p[10] - points Edited by author 28.11.2023 11:41 No need to use simplex alg. Simple brute force linear programming done in O( Choose(10,4) * 4^3 ) time The 2nd test on the site does not pass, everything works for me, what should I do? |
|