|
|
Common BoardWhat is test 2? I may be wrong but it might be something like this. for (int i = 0; i < 1 << 16; i++) cout << (char)('a' + __builtin_popcount(i) % 2); Edited by author 15.04.2015 18:12 New tests have been added, 24 authors have lost AC. var min1 = n; var min2 = n; for (var i = 0; i < k; i++) { var a = vals[i]; if (a < min1) { min2 = min1; min1 = a; } else if (a < min2) min2 = a; } Console.WriteLine(Math.Max(min1 + min2 - n, 0)); If you get WA on test #8, don't forget about mod = 1000000007 :) Can somebody give me some hints on Test 3 ? I get WA but don't know why. I 've run all other test in the forum and it gives right answer 5 Isenbaev A B A B C D Q P C H N G N P output: --------------------------------------- A 1 B 1 C 2 D 5 G 4 H 3 Isenbaev 0 N 3 P 4 Q 5 --------------------------------------- Edited by author 04.01.2015 15:44 My program pases it, but I still have WA4. I got AC, problem was small capacity of my arrays :-) Edited by author 13.04.2015 00:22 I got wrong 13 times because I ignored this sentence: Those characters are situated on the consecutive lines grouped by 80 characters per line without any spaces. Edited by author 03.05.2015 13:31 "There is no subordinate of ordinary employees" vs "an arbitrary employee who has subordinates (an ordinary employee)" that is my code #5 test case is the error #include<iostream> #include<cstring> using namespace std; int main() { char nmat[1000][31]; long int no=0; long int n; cin>>n;
cin.ignore(); if(1<=n && n<=1000) { for(int i=0;i<n;i++) cin.getline(nmat[i],30);
for(int i=1;i<n;i++) { for(int j=i-1;j>=0;j--) { if((strcmp(nmat[i],nmat[j]))==0) { no++; break; }
} }
cout<<no; system("pause"); return 0; }
} Remember to remove any possible padding of the struct: for example, in MSVC do #pragma pack(push, 1) before the struct definition. May be this tests can help you, my friends: 7 4 4 4 5 6 7 5 Answer: 3 5 5 4 4 4 5 5 Answer: 3 5 10 2 3 4 1 1 2 3 4 7 9 Answer: 4 7 Good luck! Edited by author 11.04.2015 21:18 where is non-zero exit code in my code solving Bayan problem please help me #include<iostream> #include<cstring> using namespace std; int main() { char nmat[1000][31]; int no=0; int n; cin>>n; cin.ignore(); if(1<=n&&n<=1000) { for(int i=0;i<n;i++) cin.getline(nmat[i],30); for(int i=1;i<n;i++) { for(int j=i-1;j>=0;j--) { if((strcmp(nmat[i],nmat[j]))==0) { no++; break; } } }
cout<<no; } system("pause"); return 0; } #include <cstdio> int main() { unsigned N, i, discharge, count; unsigned long *array; scanf("%u", &N); array = new unsigned long [N]; for(i = 0; i < N; i++) scanf("%lu", &array[i]); for(i = 0; i < N; i++) { discharge = 1; for(count = 0; discharge <= array[i]; count++) discharge += count; discharge--, count--; if(discharge - (count - 1) == array[i]) printf("%d%c", 1, ' '); else printf("%d%c", 0, ' '); }
return 0; } Can smb help me? I got WA3,a AC program getWA3, too. I think all ok. For all : be attantive with start values of array (not zero but -inf!!!) I think all ok. For all : be attantive with start values of array (not zero but -inf!!!) thank you very much! Hi PSV, thanks for the help in finding mistake in my program :) Hi guys, i tryed to solve this problem with the treap (the randomized binary search tree ). It works for O(N*logN) , but i got TLE!!!!! For examlpe, i tryed to solve one problem (1208) with bruteforce (2^18 * 18), and i also got TLE, but on the CodeForces in max case, i got MAX : 0.3ms on the same complillers... Maybe you shouldn't put such small time limits? (Soz for Eng) // The code compiles and works fine. (It expects Ctrl+Z to stop user's input). #include <iostream> #include <math.h> #include <vector> #include <stdio.h> using namespace std; int main(){ unsigned long long a; vector<unsigned long long> b; cin.clear(); while (cin >> a, !cin.eof()) { b.push_back(a); }
for (vector<unsigned long long>::reverse_iterator it = b.rbegin(); it != b.rend(); ++it){ printf("%.4f\n", sqrt((long double)*it));
}
return 0; } #include <iostream> #include <math.h> #include <vector> #include <stdio.h> using namespace std; int main(){ unsigned long long a; vector<unsigned long long> b; cin.clear(); while (cin >> a ) { b.push_back(a); if (cin.eof()) break; } for (vector<unsigned long long>::reverse_iterator it = b.rbegin(); it != b.rend(); ++it){ printf("%.4f\n", sqrt((long double)*it)); } return 0; } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Name { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); if ((1 >= a)&&(a<=4)) Console.WriteLine("few"); if ((5 >= a)&&(a<=9)) Console.WriteLine("several"); if ((10 >= a)&&(a<=19)) Console.WriteLine("pack"); if ((20 >= a)&&(a<=49)) Console.WriteLine("lots"); if ((50 >= a)&&(a<=99)) Console.WriteLine("horde"); if ((100 >= a)&&(a<=249)) Console.WriteLine("throng"); if ((250 >= a)&&(a<=499)) Console.WriteLine("swarm"); if ((500 >= a)&&(a<=999)) Console.WriteLine("zounds"); if (1000 >= a) Console.WriteLine("legion"); } } } (1 >= a)&&(a<=4) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Name { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); if ((1 >= a)&&(a<=4)) Console.WriteLine("few"); if ((5 >= a)&&(a<=9)) Console.WriteLine("several"); if ((10 >= a)&&(a<=19)) Console.WriteLine("pack"); if ((20 >= a)&&(a<=49)) Console.WriteLine("lots"); if ((50 >= a)&&(a<=99)) Console.WriteLine("horde"); if ((100 >= a)&&(a<=249)) Console.WriteLine("throng"); if ((250 >= a)&&(a<=499)) Console.WriteLine("swarm"); if ((500 >= a)&&(a<=999)) Console.WriteLine("zounds"); if (1000 >= a) Console.WriteLine("legion"); } } } Can somebody share test case #5? |
|
|