Общий форумThis is a big point I think should take care. this is my code in C++ but the system does not accept it. please help me. --------------------------------------------------------------- #include<iostream> using namespace std; int main() { long long int nums[100][100]; char x[90]; int n, m; long long int id, temp; cin>>n; for(int i=0; i<n; i++) { cin>>id>>m; nums[i][0]=id; nums[i][1]=m; } for(int i=0; i<n; i++) { for(int j=i+1; j<n; j++) { if(nums[j][1]>nums[i][1]) { temp=nums[j][0]; nums[j][0]=nums[i][0]; nums[i][0]=temp; temp=nums[j][1]; nums[j][1]=nums[i][1]; nums[i][1]=temp; } } } for(int i=0; i<n; i++) { cout<<nums[i][0]<<" "<<nums[i][1]<<endl; } return 0; } Edited by author 03.11.2012 14:25 It will get TLE, because it works in N^2. Такой вывод для первого теста подходит, т.к. "говорит" WA2 Console.Write("3 5\n26 4\n22 4\n16 3\n20 3\n1 2\n11 2\n7 1\n"); А этот WA1. В упор... =( . -------------------------------- using System; using System.Collections.Generic; class Program { struct TRec { public int ID, M; } static int Comp(TRec x, TRec y) { if (y.M < x.M) return -1; else if (y.M > x.M) return 1; else return 0; } static void Main() { int N = int.Parse(Console.ReadLine()); List<TRec> D = new List<TRec>(); string[] RecStr; for (int i = 0; i < N; i++) { RecStr = Console.ReadLine().Split(' '); TRec R = new TRec(); R.ID = int.Parse(RecStr[0]); R.M = int.Parse(RecStr[1]); D.Add( R ); } D.Sort(Comp); foreach (TRec X in D) Console.Write("{0} {1}\n", X.ID, X.M); Console.ReadLine(); } } Делаю в C#2012. Неужто в 2010 quick_sort работает по другому? hi! Need to use stable sort. I add extra field - ind, to compare 2 entry. using System; using System.Collections.Generic; class Program { struct TRec { public int ID, M, ind;} static int Comp(TRec x, TRec y) { if (y.M < x.M || (y.M == x.M && y.ind > x.ind)) return -1; if (y.M > x.M || (y.M == x.M && y.ind < x.ind)) return 1; return 0; } static void Main() { int N = int.Parse(Console.ReadLine()); List<TRec> D = new List<TRec>(); string[] RecStr; for (int i = 0; i < N; i++) { RecStr = Console.ReadLine().Split(' '); TRec R = new TRec(); R.ID = int.Parse(RecStr[0]); R.M = int.Parse(RecStr[1]); R.ind = i; D.Add(R); } D.Sort(Comp); foreach (TRec X in D) Console.Write("{0} {1}\n", X.ID, X.M); Console.ReadLine(); } } very strange, when using printf("%lld", ans); -> WA6 however, cout << ans << endl; ->AC same WA6 for me, but: printf("%I64d\n", answer); -> AC Обратите внимание на результат при N = 1000000000. А точнее на его размер 555555555888 в 32 бита он не поместится. 8 тест из-за этого выдает "Wrong answer". Hi i'm getting WA for #10, can anyone help with this? My code works for everything ive tested so far public static void main( String [] args){ int a,b; Scanner sc = new Scanner(System.in); a = sc.nextInt(); b = sc.nextInt(); int[] array = new int[b]; for( int i = 0; i < b; i++) array[i] = sc.nextInt(); int carry = 0; for( int i = 0; i < b; i++){ array[i] = array[i] + carry; if(array[i] > a) carry = array[i]%a; else carry = 0; array[i] = array[i] - carry; } int answer=0; array[b-1]+=carry; int current = 0; for( int i = 0; i < b; i++){ if(array[current] <= a){ array[current] = 0; current++; } else array[current] = array[current] - a; } for( int i = 0; i < b; i++) answer+=array[i]; System.out.println(answer);
} Edited by author 05.08.2013 14:55 Edited by author 05.08.2013 17:31 subj I didnt use ull & got AC. At first I was also pissed off but this problem is awesome in that it makes you remember forever that you need to first read input/ouput rather than problem itself! #include<iostream> #include<stdio.h> #include<stack> #include<cmath> using namespace std; int main () { stack <unsigned long long int> a; unsigned long long int num; while (scanf("%llu",&num)!=EOF) { a.push(num); } for (;;) { printf("%.4lf\n",double(sqrt(double(a.top())))); a.pop(); if (a.empty()==1) break; } return 0; } That's my code. I have WA1. But my program writes right answer for the sample test. Where is my mistake is it printf (i tried with cout but the result was the same.)? Edited by author 04.08.2013 17:29 I have a problem with 5 test case. Firs I had Runtime Error, when I add lines: if(nextWord == null) continue; Runtime Error changed to WA. I'm using Java and i read my input as follow: StreamTokenizer in = in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); private static int nextInt() throws IOException { in.nextToken(); return (int) in.nval; } private static String nextString() throws IOException { in.nextToken(); return in.sval; } Somebody had a wrong answer in test 6? I can't understand what exactly can be wrong :( Please, help I had it when my program printed Perfect when FPS was 59.9 Edited by author 03.08.2013 14:32 Please explane what is K. What it means K=10? Ok now I get it. Why then did not explain to others? Bin: K = 2, [0,1] Oct: K = 8, [0,1,2,3,4,5,6,7] (или [0..7]) Dec: K = 10, [0,1,2,3,4,5,6,7,8,9] (или [0..9]) Hex: K = 16, [0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F] (или [0..F]) То есть список цифр из которых может состоять К-ичное число = [0..K-1]. PS: В задаче K не > 10. Значит буквы не участвуют. To those who WA 8: Try to change your epsilon to something else then 1e-14. I changed that to 1e-8 and then I got AC. Also, don't calculate S△ABC as 0.5*AB*AC! It should be 0.5*AB*AC*sin∠A As I see - your advice is to use greater epsilon. May be it is better to avoid dangerous computations? I've solved this problem in integers - so all comparations were EXACT =) So, I think, the note about precision in problem text is superfluous. How did you solved it? My first solution was with integers but than i noticed not all squares are axes aligned. :( Anyway, could you send me you solution? My email is marshal at mail.bg. Thank you! I got AC without epsilon;) Edited by author 03.08.2013 03:37 Name of a compartment might consists digits. wrong answer test 13 why Because your solution are wrong. Cool answer. I'm sorry, but your English is bad. Solution can't be 'are'. Don't it mean he only deliver one whisky on one day? I don't know the test while the others programmer offer... Who can tell me what the problem mean? example : 3 1 10 (order: 1) 2 15 (order: 2) 2 17 (order: 3) the answer: 2 2 3 ``````` The result don`t have (order: 1), because the last arrive day is 2, mean the man deliver twice, one day one once, the subject mean it find out max profit in no more than the last day 4 1 17 5 20 2 10 2 11 answer: 3 1 4 2 Do you understand ? Edited by author 30.12.2008 17:17 Can I answer in the first test "3 2"? Nope) "1 4 2" answer gives a 17+11+15=43$ reward. And there is no other sequence of delivery that will give us $43 reward. "If there are several solutions, output any of them." using System; namespace ConsoleApplication4 { class Program { static void Main() { int x = 1; do { Console.WriteLine("введите число"); String строка = Console.ReadLine(); Single X; X = Single.Parse(строка); { if (X <= 4 && X >= 1 ) { Console.WriteLine(" few");} if( X <= 9 && X >= 5) { Console.WriteLine("several"); } if (X <= 19 && X >= 10 ) {Console.WriteLine("pack");} if( X <= 49 && X >= 20) { Console.WriteLine("lots");} if (X <= 249 && X >= 100) { Console.WriteLine("throng"); } if (X <= 99 && X >= 50) { Console.WriteLine("horde"); } if (X <= 499 && X >= 250) { Console.WriteLine("swarm"); } if (X <= 999 && X >= 500) { Console.WriteLine("zounds"); } if ( X <= int.MaxValue && X >= 1000 ) { Console.WriteLine("legion"); } } } while (x != 0); } } } using System; namespace ConsoleApplication4 { class Program { static void Main() { int x = 1; String строка = Console.ReadLine(); Single X; X = Single.Parse(строка); { if (X <= 4 && X >= 1) { Console.WriteLine("few"); } if (X <= 9 && X >= 5) { Console.WriteLine("several"); } if (X <= 19 && X >= 10) { Console.WriteLine("pack"); } if (X <= 49 && X >= 20) { Console.WriteLine("lots"); } if (X <= 249 && X >= 100) { Console.WriteLine("throng"); } if (X <= 99 && X >= 50) { Console.WriteLine("horde"); } if (X <= 499 && X >= 250) { Console.WriteLine("swarm"); } if (X <= 999 && X >= 500) { Console.WriteLine("zounds"); } if (X <= int.MaxValue && X >= 1000) { Console.WriteLine("legion"); } } } } } This topic is devoted to trolled ppl :D God damn it I was ashamed after typing so many string super duper cumbersome functions XD |
|