Show all threads Hide all threads Show all messages Hide all messages | AC | Dashka_Bu | 1581. Teamwork | 30 Dec 2017 16:27 | 3 | AC Dashka_Bu 10 Mar 2012 20:11 program idiots; var n,i,h:integer; a: array [1..1000] of integer; begin readln(n); for i:=1 to n do read(a[i]); h:=1; for i:=1 to n do begin if a[i]=a[i+1] then h:=h+1; if a[i]<> a[i+1] then write(h,' ',a[i],' '); if a[i]<> a[i+1] then h:=1; end; end. Re: AC kami_botanik 14 Mar 2013 20:05 but, I don't understood! for i:=1 to n do begin if a[i]=a[i+1] then h:=h+1; if a[i]<> a[i+1] then write(h,' ',a[i],' '); if a[i]<> a[i+1] then h:=1; end; You must get error in this stroke if a[i]=a[i+1] then h:=h+1; because your for loop is going untill n this must give Indexout of range exception isn't? Re: AC SeaEagle 30 Dec 2017 16:27 Nope, its neither c++ nor Java. It`s Pascal. Here you can do a lot of forbidden things without getting runtime error or Exception | WA #2 | Apurv Nagar | 1581. Teamwork | 12 Jun 2016 13:54 | 3 | WA #2 Apurv Nagar 6 Apr 2016 18:41 below is my java code: import java.util.*; public class timus1581 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); if (t>=1 && t<=1000) { int i = 0; int cnt = 0; int a[] = new int[t]; for (i = 0; i <= t-1; i++) { a[i] = sc.nextInt(); if (a[i]>=1 && a[i]<=10) { continue; } else { System.exit(0); } } for (i = 0; i < t-1; i++) { if (a[i] == a[i+1]) { cnt++; } else { System.out.print((cnt+1) + " " + a[i] + " "); cnt = 0; } if (t == i + 2) { System.out.print((cnt+1) + " " + a[i]); cnt = 0; } } } } } Edited by author 09.04.2016 14:32 System.out.println("Enter no. of test cases"); System.out.println("Enter Integers"); How do you think a robot would distinguish those messages from your real answer. http://acm.timus.ru/help.aspx?topic=judge«The program must print only the data that is required by the problem statement. The program must not print any prompts (“Enter N:”). The program must not wait for pressing a key at the end of execution.» Re: WA #2 Alexandr Vasilyev 12 Jun 2016 13:54 for (i = 0; i < t-1; i++) { if (a[i] == a[i+1]) { cnt++; } else { System.out.print((cnt+1) + " " + a[i] + " "); cnt = 0; } if (t == i + 2) { System.out.print((cnt+1) + " " + a[i]); cnt = 0; } } I am not understand this part. Edited by author 12.06.2016 13:59 | WA #5 JAVA, SOMEONE CAN HELP ME? HERE IS MY CODE | Julius | 1581. Teamwork | 26 Nov 2015 06:04 | 2 | import java.io.PrintWriter; import java.util.Scanner; public class P1581 { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int [] vec=new int[n]; for(int i=0;i<n;i++)vec[i]=in.nextInt(); int cont=0,num; num=vec[0]; for(int i=0;i<n;i++){ if(vec[i]==num){ cont=cont+1; } if(vec[i]!=num || i+1==n){ if(i+1!=n){ System.out.printf("%d %d ",cont,num); }else{ System.out.printf("%d %d",cont,num); } num=vec[i]; cont=1; }
} out.flush(); } } ---- THANKS YOU, GREETINGS. Edited by author 26.11.2015 05:45 nub qlo int cont=0,num; num=vec[0]; for(int i=0;i<n;i++){ if(vec[i]==num){ cont=cont+1; } if(vec[i]!=num ){ System.out.printf("%d %d ",cont,num); num=vec[i]; cont=1; } } System.out.printf("%d %d",cont,num); | [JAVA] Why is it wrong answer? My program works correctly on my computer. | icytwister | 1581. Teamwork | 26 Nov 2015 05:51 | 2 | import java.util.*; public class timusTeam { public static void main(String [] args) { int i=0; Scanner in=new Scanner(System.in); int n=in.nextInt();
if(n>1000 || n<1) return;
int arr[]=new int[n]; for(i=0;i<n;i++) { arr[i]=in.nextInt(); if(arr[i]>10 || arr[i]<0) return; }
int a; int sum=0;
i=0; while(i<n) { a=arr[i]; for(int k=0;k<n;k++) if(arr[k]==a) { sum++; i++; } System.out.print(sum +" " +a +" "); sum=0; }
} } im frustrated :( Help me please Edited by author 05.06.2012 16:59 Edited by author 05.06.2012 18:21 6 1 1 2 1 1 1 5 1 5 1 BUILD SUCCESSFUL (total time: 6 seconds) answer -> 2 1 1 2 3 1 BUILD SUCCESSFUL (total time: 4 seconds) You 're telling the amount of x number on the table, read again the problem, greetings. Edited by author 26.11.2015 05:52 | Whats the problem? WA #4 | ELDVN | 1581. Teamwork | 1 Nov 2015 14:28 | 2 | #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <map> #include <stack> #include <algorithm> #include <bitset> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <iomanip> #define F first #define S second #define ll long long #define len length() #define sqr(x) x*x #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define bp(x) __builtin_popcount(x) #define INF numeric_limits<long long int>::max() #define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std;
int n; int a[1010]; main(){ scanf("%d",&n); for(int i=1; i <= n; i++){ int x; scanf("%d",&x); a[x]++; } for(int i=0; i <= 10; i++){ if(a[i] > 0) printf("%d %d ",a[i], i); }
return 0; } I write the same logic, but first my code got WA #4. Second is accept! Wtf ? :D #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <map> #include <stack> #include <algorithm> #include <bitset> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <iomanip> #define F first #define S second #define ll long long #define len length() #define sqr(x) x*x #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define bp(x) __builtin_popcount(x) #define INF numeric_limits<long long int>::max() #define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std;
int n; int cnt=1,ans; int a[1010]; main(){ scanf("%d",&n); for(int i=1; i <= n; i++){ scanf("%d",&a[i]); } for(int i=1; i <= n; i++){ if(a[i]==a[i+1]){ cnt++; ans=a[i+1]; } else{ ans=a[i]; printf("%d %d ",cnt,ans); cnt=1; } }
return 0; } | 4 test !? | Vigi | 1581. Teamwork | 14 Oct 2015 10:26 | 1 | from math import sqrt n = int(input()) l = list(map(int, input().split())) t = [] for i in range(n): for j in range(n): if l[i] == l[j]: t.append(l[i]) l = 0 for i in range(len(t)): if t[i] != l: print(int(sqrt(t.count(t[i]))),t[i], end=' ') l = t[i] что за тест в чем ошибка? | WA for Test 8 | nrl | 1581. Teamwork | 2 Oct 2015 01:09 | 5 | Anyone have idea what could be the problem ?? Any test case you would suggest ? Thanks Yes When i run it on my machine the answer for 1 4 is 1 4 I am using byte array, should i use int array instead.. ?? Idk how but it worked for an earlier problem I changed the byte array to short Now I get the above test case wrong.. Why so ???!!! | It is very easy, here is my solution | Dimaphil | 1581. Teamwork | 4 Jun 2015 09:13 | 3 | var a, b : array[1..1000] of integer; n, i, k : integer; begin readln(n); for i := 1 to n do begin read(a[i]); end; i := 2; k := 1; while i <= n + 2 do begin if a[i] = a[i - 1] then begin k := k + 1; i := i + 1; end else begin write(k,' ',a[i - 1],' '); i := i + 1; k := 1; end; end; end. Please explain, why my cod has WT7 and your not) var a:array[1..1000] of integer; i,n,k:integer; Begin readln(n); for i:=1 to n do begin read(a[i]); end; k:=1; i:=2; while i<=n+2 do begin if a[i]=a[i-1] then begin i:=i+1; k:=k+1; end else begin write(k,' ',a[i-1],' '); i:=i+1; k:=1; end; end; End. Edited by author 26.11.2012 23:44 Edited by author 26.11.2012 23:44 #include <bits/stdc++.h> using namespace std; #define maxx 500 #define pb push_back #define pii pair<int,int> queue<int>qu; vector<pii>vpii[maxx]; #define inf 0x7fffffff int X[]={+2,+2,-2,-2,+1,-1,-1,+1}; int Y[]={-1,+1,-1,+1,+2,+2,-2,-2}; int main() { int n,u; cin>>n; vector<int>v; for(int i=0;i<n;i++) { cin>>u; v.pb(u); } int cnt=1,l; for(int i=0;i<v.size();i++) { if(v[i]==v[i+1]) { cnt++; l=v[i+1]; } else{ l=v[i]; cout<<cnt<<" "<<l<<" "; cnt=1; } } return 0; } | WA4 ...i don't understand! | Nextatix | 1581. Teamwork | 21 Apr 2015 15:37 | 1 | import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
Map<Integer, Integer> m = new TreeMap<Integer, Integer>();
in.nextToken(); int nv = 0; int count = (int)in.nval;
for(int i=0; i<count; i++) { in.nextToken(); nv = (int)in.nval; if(m.containsKey(nv)) m.put(nv,(int)(m.get(nv)+1)); else m.put(nv, 1); }
for(int i : m.keySet()) { out.print(m.get(i)); out.print(' '); out.print(i); out.print(' '); }
out.flush(); } } | c++ AC | amirshir | 1581. Teamwork | 11 Jan 2015 23:19 | 1 | c++ AC amirshir 11 Jan 2015 23:19 #include <iostream> using namespace std; int main() { int n ; cin>>n ; int f,s,l ; for(int i=0;i<n;i++) { cin>>s ; if(i==0) { l=s ; f=1 ; } else if(l!=s) { cout<<f<<" "<<l<<" " ; f=1 ; l=s ; } else f++ ; } cout<<f<<" "<<l ; } | WA 4 | mushfiq | 1581. Teamwork | 16 Nov 2014 02:40 | 2 | WA 4 mushfiq 24 Oct 2014 18:03 What is test case 4? please help yes, give 4 test Edited by author 16.11.2014 02:42 | Java WA could you give advice ? | Alex | 1581. Teamwork | 8 Nov 2013 08:20 | 1 | resolved Edited by author 08.11.2013 09:29 Edited by author 08.11.2013 09:29 | Why WA4 | KartonArmadon | 1581. Teamwork | 24 Sep 2013 18:16 | 1 | Why WA4 KartonArmadon 24 Sep 2013 18:16 Sorry please, i find mistake... Edited by author 24.09.2013 18:26 | WA test 4 help me, please! | Abdulaziz | 1581. Teamwork | 21 Jul 2013 15:01 | 2 | #include <iostream> using namespace std; int main() { int n, i, j; cin>>n; int a[n], s=0, s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0, s8=0, s9=0, s10=0; for(i=1; i<=n; i++) cin>>a[i]; for(i=1; i<=n; i++) { if(a[i]==1) s1++; if(a[i]==2) s2++; if(a[i]==3) s3++; if(a[i]==4) s4++; if(a[i]==5) s5++; if(a[i]==6) s6++; if(a[i]==7) s7++; if(a[i]==8) s8++; if(a[i]==9) s9++; if(a[i]==10) s10++; //if(a[i]==0) s++;
} if(s1==0) cout<<""; else cout<<s1<<" "<<"1 "; if(s2==0) cout<<""; else cout<<s2<<" "<<"2 "; if(s3==0) cout<<""; else cout<<s3<<" "<<"3 "; if(s4==0) cout<<""; else cout<<s4<<" "<<"4 "; if(s5==0) cout<<""; else cout<<s5<<" "<<"5 "; if(s6==0) cout<<""; else cout<<s6<<" "<<"6 "; if(s7==0) cout<<""; else cout<<s7<<" "<<"7 "; if(s8==0) cout<<""; else cout<<s8<<" "<<"8 "; if(s9==0) cout<<""; else cout<<s9<<" "<<"9 "; if(s10==0) cout<<""; else cout<<s10<<" "<<"10 "; cout<<endl; "<<s8<<" 8 "<<s9<<" 9 "<<s10<<" 10 "; } твоя прога не пройдет тест 1 1 2 2 2 1 1 1 | Не могу пройти 1 тест, помогите | fotol | 1581. Teamwork | 12 May 2013 19:51 | 1 | var x,n,m,y,i1,i,code:integer; a,k:array[1..100] of integer; c:array[1..100] of string; s:string; t:boolean; begin repeat readln(n); until (n>0) and (n<1001); for i:=1 to n do begin readln(a[i]); if a[i]<=0 Then t:=true; end; i:=2; x:=1; If t=false Then begin For i:=2 to n do begin if a[i-1]=a[i] Then x:=x+1 else begin write(x,' ',a[i-1],' '); x:=1; end; end; if n<>1 THEN write(x,' ',a[i]) ELSE write(x,' ',a[i-1]); end end. | Judges, problem description is not correct. | OZone | 1581. Teamwork | 5 Apr 2013 21:52 | 2 | | i dont understand this bug | shayan shafiee | 1581. Teamwork | 3 Apr 2013 19:56 | 1 | //please help me to solve this problem //my Bug is between the stars. #include <iostream> using namespace std; int main() { int n,s=1; cin >> n; int a[n]; for( int i=0;i<n;i++ ) { cin >> a[i]; } for( int i=0;i<n-1;i++ ) { if( a[i]!=a[i+1] ) s++; } int b[s][2]; for( int i=0;i<s;i++ ) { b[i][1]=-1; b[i][0]=0; } b[0][0]=1; b[0][1]=a[0]; //************************************************************************** for( int i=0; i<n-1;i++ ) { if( a[i]!=a[i+1] ) { int j; for( j=1;j<s;j++ ) { if( b[j][1]=-1 ) break; } b[j][1]=a[i+1]; b[j][0]++; } else if( a[i]==a[i+1] ) { int j; for( j=1;j<s;j++ ) { if( b[j][1]=-1 ) break; } b[j-1][0]++; } } //************************************************************************** for( int i=0;i<s;i++ ) { cout << b[i][0] << " " << b[i][1]<< " "; } return 0; } | WHY WA5 ? | Iuhenio{PSU} | 1581. Teamwork | 11 Feb 2013 21:43 | 1 | Edited by author 11.02.2013 22:27 Edited by author 11.02.2013 22:27 | Why CE ?? | Александр | 1581. Teamwork | 16 Oct 2012 16:33 | 1 | #include<stdio.h> int main() { int N; scanf("%d", &N); int start; scanf("%d", &start); int sum = 1; for(int i = 1; i < N; i++) { int a; scanf("%d", &a); if(a == start) { sum++; } else { printf("%d %d ", sum, start); start = a; sum = 1; } } printf("%d %d ", sum, start); return 0; } | what is test 4 ? my code here: | Tom | 1581. Teamwork | 1 May 2012 13:53 | 2 | it gives good output for every test i came up with... i dont know where is the mistake and code is very simple help pls #include <iostream> using namespace std; int main(){
int n,i; int* tab; int tabL[11]={0}; cin >> n; tab = new int [n]; for(i=0;i<n;i++){ cin >> tab[i]; tabL[tab[i]]++; } for(i=0;i<11;i++){ if(tabL[i]!=0){ cout << tabL[i] << " " << i << " "; } } getchar();getchar(); return 0; } |
|
|