Общий форум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? 443 -39 457 33 386 -773 561 127 Correct answer: -1 Here are some tests: 5 6 1 1 1 2 Answer: 1 5 6 1 2 2 6 Answer: 5 5 6 1 5 2 6 Answer: 2 5 6 1 5 1 2 Answer: 3 (Here I think you may have WA, because second point occur first) 5 6 2 3 3 3 Answer: 9 Good Luck!!! My prog passes all of this test but still wa4.why? Test 4 contains (1,1) as second point imho. #include <stdio.h> void main(void) { long a[4000],b[4000],c[4000],i,ai,bi,ci,aj,bj,cj,sum=0; scanf("%d",&aj); for(ai=0;ai<aj;ai++) scanf("%d",&a[ai]); scanf("%d",&bj); for(bi=0;bi<bj;bi++) scanf("%d",&b[bi]); scanf("%d",&cj); for(ci=0;ci<cj;ci++) scanf("%d",&c[ci]); for(ai=0;ai<=aj;ai++) { for(bi=0;bi<=bj;bi++) { if(a[ai]==b[bi]) { for(ci=0;ci<=bj;ci++) { if(a[ai]==c[ci]) sum++; } } } } printf("%d",sum); } #include <iostream> #include <cmath> #include <stack> using namespace std; int main() { stack <unsigned long long> __stack_sqrt; unsigned long long ent_val; while(cin >> skipws >> ent_val) __stack_sqrt.push(ent_val); cout.setf(ios::showpoint); cout.precision(5); while(!(__stack_sqrt.empty())) { cout << sqrt(__stack_sqrt.top()) << endl; __stack_sqrt.pop(); } return 0; } Compilator wrote "wrong answer", but when i've test it, everything is ok! Please help smb, what's th problem? initially, there is "sun" in the DATABASE. Can't catch where is error. Is there an error in my algorythm? х - energy quantum, amount of which is calculated by division (power_supply/sqr(d)), where 'power_supply' is amount of energy stored by previous save action and 'd' is an area in which wall segments are enforced. Energy portion for each segment is calculated by formula (d-delta)*x, where delta is a distance from the targeted segment. After energy distribution I just set power_supply to 0. Also energy saving and wall enforcing occurs after energy is generated for time passed from previous action. Edited by author 11.09.2013 19:50 If you get WA/RE on 7th test it makes sense to read statement carefully : n can be up to 10^9. Could you give me some tests to train my code? I WA in test 6 many times and I don't know why anymore.. I need some people to help me. Here is my code: #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace std; int sg[55][110][110]; int a[110][110]; int n; bool v[110], l[110]; int mex ( int l, int r, int x ){ if ( sg[x][l][r] != -1 ) return sg[x][l][r]; if ( l > r ) return 0; int i, j, k; int p, ss; memset ( v, false, sizeof (v) ); for ( i = l; i <= r; i ++ ){ p = a[x][i]; ss = 0; k = l; for ( j = l; j <= r; j ++ ){ if ( a[x][j] <= p ){ ss ^= mex ( k, j-1, x ); k = j+1; } } ss ^= mex ( k, r, x ); v[ss] = true; } for ( i = 0; ; i ++ ){ if ( v[i] == false ){ sg[x][l][r] = i; return i; } } } int get_sg ( int x ){ int i, j, k; for ( i = 1; i <= a[x][0]; i ++ ) sg[x][i][i] = 1; return mex ( 1, a[x][0], x ); } void get_way ( int ans ){ int i, j, k, x, y, o; int p, s; for ( i = 1; i <= n; i ++ ){ for ( j = 1; j <= a[i][0]; j ++ ){ p = a[i][j]; s = 0; o = 1; for ( k = 1; k <= a[i][0]; k ++ ){ if ( a[i][k] <= p ){ s ^= mex ( o, k-1, i ); o = k+1; } } s ^= mex ( o, a[i][0], i ); if ( (ans^sg[i][1][a[i][0]]^s) == 0 ){ printf ( "%d %d\n", i, j ); return; } } } } int main (){ int i, j, k; scanf ( "%d", &n ); k = 0; memset ( sg, -1, sizeof (sg) ); for ( i = 1; i <= n; i ++ ){ scanf ( "%d", &a[i][0] ); for ( j = 1; j <= a[i][0]; j ++ ) scanf ( "%d", &a[i][j] ); get_sg (i); k ^= sg[i][1][a[i][0]]; } if ( k == 0 ) printf ( "S\n" ); else{ printf ( "G\n" ); get_way (k); } return 0; } #include <iostream> using namespace std; bool Chekcker(int A[],int k) { int i,j,v; bool circle=true; for(j=1;j<=k;j++) for(v=1;v<=k;v++) { if(A[v]==0 && A[j]==v ) A[j]=0; }
for(j=1;j<=k;j++) for(v=1;v<=k;v++) { if(A[j]==0 && A[v]==j ) A[v]=0; } for(v=1;v<=k;v++) if(A[v]==0) { circle=true;} else{circle=false;break;} return circle; } int main() { int n; cin>>n; int i,j,k = 0,v; int temK; bool circle; int conf; int A[30000]; for(i=1;i<=n;i++) { cin>>k; j=1; v=1; temK=k; circle=true; conf=0;
for(j=1;j<=k;j++) { cin>>A[j];
}
for(j=1;j<=k;j++) { if(A[j]==0) conf++; }
circle=Chekcker(A,k);
if(conf==0 || conf>1) {circle=false;}
if(circle==true) cout<<"YES"<<endl; else cout<<"NO"<<endl;
for(v=1;v<=k;v++) A[v]=0; }
return 0; } this code get correct on every test in the forum, however fails test #3. Whats Wrong???? PLS GUYS HELP ME WITH WA#26 MY AZZ IS VERYYY HOOOOT because of this test Edited by author 02.04.2015 23:22 |
|