Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | test 7 | alex kichkin | 1837. Число Исенбаева | 27 июл 2012 00:49 | 2 | test 7 alex kichkin 7 янв 2012 13:48 what is the test #7? I have tried my own tests, my program outputs right answers, i don't know what to do try this: 2 A B C Isenbaev A D answer is: A 1 B 2 C 2 D 1 Isenbaev 0 | WA#10 | sty110112 | 1837. Число Исенбаева | 8 июл 2012 04:20 | 2 | WA#10 sty110112 8 май 2011 10:59 same here. u seem have a correction for it. Can you tell me what's it ? :D | I get wa 7, please give me test 7 | JAVATAR | 1837. Число Исенбаева | 7 май 2012 16:54 | 5 | Hello, What is on test 7?I get wa7 but tried all cases.please help. here is my program. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; /** * * @author Imran */ public class IsenbaevsNumber {
public static void main(String args[]) throws IOException{
Map m1=new HashMap(); Map m2=new HashMap(); List<Group> participantGroups=new ArrayList<Group>();;
InputStreamReader isr=new InputStreamReader(System.in); BufferedReader bfr=new BufferedReader(isr);
int n=Integer.parseInt(bfr.readLine()); int i=0; StringBuilder sb; int id=0;
while(i<n){ i++; //read the string sb=new StringBuilder(bfr.readLine());
//get first participant String p1=sb.substring(0, sb.indexOf(" ")); sb.delete(0,sb.indexOf(" ")+1); //get second participant String p2=sb.substring(0, sb.indexOf(" ")); sb.delete(0,sb.indexOf(" ")+1); //get third partisipant String p3=sb.toString();
Participant po1=(Participant)m1.get(p1); int mm=4;
if(p1.equals("Isenbaev")||p2.equals("Isenbaev")||p3.equals("Isenbaev")) mm=2;
if(po1==null){ if(p1.equals("Isenbaev")) po1=new Participant(p1, 0,id); else po1=new Participant(p1, mm,id); m1.put(p1, po1); m2.put(po1.id, po1); id++; }
Participant po2=(Participant)m1.get(p2); if(po2==null){ if(p2.equals("Isenbaev")) po2=new Participant(p2, 0,id); else po2=new Participant(p2, mm,id); m1.put(p2, po2); m2.put(po2.id, po2); id++; }
Participant po3=(Participant)m1.get(p3); if(po3==null){ if(p3.equals("Isenbaev")) po3=new Participant(p3, 0,id); else po3=new Participant(p3, mm,id); m1.put(p3, po3); m2.put(po3.id, po3); id++; }
Group g=new Group(); g.p1id=po1.id; g.p2id=po2.id; g.p3id=po3.id;
participantGroups.add(g); }
int[][] graph=new int[id][id]; for(int j=0;j<participantGroups.size();j++){
graph[participantGroups.get(j).p1id][participantGroups.get(j).p2id]=1; graph[participantGroups.get(j).p2id][participantGroups.get(j).p3id]=1; graph[participantGroups.get(j).p1id][participantGroups.get(j).p3id]=1;
graph[participantGroups.get(j).p2id][participantGroups.get(j).p1id]=1; graph[participantGroups.get(j).p3id][participantGroups.get(j).p2id]=1; graph[participantGroups.get(j).p3id][participantGroups.get(j).p1id]=1; }
for(int j=0;j<id;j++){ Participant pt=(Participant)m2.get(j); for(int k=0;k<id;k++){ Participant pt2=(Participant)m2.get(k); if(graph[j][k]==1&&pt2.value<pt.value) pt.value=pt2.value+1; }
}
List<Participant> participantsByName = new ArrayList<Participant>(m1.values()); Collections.sort(participantsByName,new NameComparator());
for( Participant par : participantsByName){ if(par.value==4) System.out.println(par.name+" undefined"); else System.out.println(par.name+" "+par.value); } } } class Participant{ int value=4; String name; int id;
Participant(String name,int value,int id){ this.name=name; this.value=value; this.id=id; }
@Override public String toString(){ return this.name; }
public void setValue(int value){ this.value=value; }
} //Comparator class NameComparator implements Comparator{ @Override public int compare(Object o1, Object o2)throws UnsupportedOperationException { Participant p1=(Participant)o1; Participant p2=(Participant)o2;
if(p1.name.compareTo(p2.name)>0) return 1; else return 0;
} } class Group{ int p1id; int p2id; int p3id; }
Ошибка в сортировке по алфавитному порядку !! тест не знаю, но ошибка точно в сортировке Thank you very much! I did not pay attention to sorting will try to fix and see. I have used something like: Person[] data = new Person[1000]; class Person implements Comparable{ // some code public int compareTo(Object o){ // here you write when to return <, =, > } } after that: Arrays.sort(data); or if you have Collection: Collections.sort(data); Edited by author 07.05.2012 16:58 | WA12 | diviator | 1837. Число Исенбаева | 5 апр 2012 22:06 | 1 | WA12 diviator 5 апр 2012 22:06 Could somebody give me 12 test ? Sory for bad my English... | WA test 30 | Student_MAT-MEX | 1837. Число Исенбаева | 7 фев 2012 19:28 | 2 | Help me please!!! What kind of mistakes can be? How many spaces (" ") can be between participants of team? Example: 3 Isenbaev Oparin Toropov Ayzenshteyn Chevdar Samsonov Ayzenshteyn Samsonov Burmistrov | WA20??test 20?? | almah | 1837. Число Исенбаева | 6 фев 2012 18:09 | 1 | please give me test 20?WA | что-то не так... на 4-том тесте ошибка | Conserj | 1837. Число Исенбаева | 27 янв 2012 10:43 | 2 | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace ConsoleApplication1 { classProgram { staticvoid Main(string[] args) { string Name = "Isenbaev"; ArrayList OF = newArrayList(); ArrayList NF = newArrayList(); int n = int.Parse(Console.ReadLine()); int[,] kol = newint[n, 3]; bool f = false; string[,] name = newstring[n, 3]; for (int i = 0; i < n; i++) { string[] s = Console.ReadLine().Split(' '); for (int j = 0; j < 3; j++) { f = true; kol[i, j] = -1; name[i, j] = s[j]; } } int t=1; OF.Add(Name); while (OF.Count != 0) { for (int z = 0; z < OF.Count; z++) { r = false; for (int i = 0; i < n; i++) { f = false; for (int j = 0; j < 3; j++) { if ((OF[z].ToString().CompareTo(name[i, j]) == 0) && (kol[i, j] == -1)) { kol[i, j] = t - 1; f = true; break; } } if (f) { for (int j = 0; j < 3; j++) { if (OF[0].ToString().CompareTo(name[i, j]) != 0) { int d=0; for (int y = 0; y < OF.Count; y++) { if (name[i, j].CompareTo(OF[y].ToString()) == 0) { d++; } } if (d == 0) { kol[i, j] = t; } NF.Add(name[i, j]); } } } } } OF.Clear(); for (int i = 0; i < NF.Count; i++) { OF.Add(NF[i]); } NF.Clear(); t++; } string[] res = newstring[n*3]; int k=0; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { if (kol[i, j] == -1) { res[k] = name[i, j] + " undefined"; } else { res[k] = name[i, j] + " " + kol[i, j]; } k++; } } Array.Sort(res); for (int i = 0; i < (n*3)-1; i++) { if (res[i].CompareTo(res[i + 1]) != 0) { Console.WriteLine(res[i]); } } if ((res[n * 3 - 1]).CompareTo(res[n * 3 - 2]) != 0) { Console.WriteLine(res[n*3-1]); } } } } Your program is not reading 3rd name. use Console.ReadLine().Split(new char[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); istead of Console.ReadLine().Split(' '); | No subject | alex kichkin | 1837. Число Исенбаева | 7 янв 2012 01:04 | 2 | people what is the test #1? Usually it's the sample test from the problem description. | No subject | wym510 | 1837. Число Исенбаева | 3 янв 2012 21:33 | 3 | output “undefined” instead of it. means instead of number or instead of that line? | WA Test 2 | Anton_Chernev | 1837. Число Исенбаева | 2 янв 2012 17:49 | 1 | Can you give me some tests. I tried lots of tests but the answer of my program is correct. Thank you. | Crash Access violation #28 | Navid | 1837. Число Исенбаева | 29 ноя 2011 21:02 | 3 | Please help ,I thought my program is correct. Edited by author 22.11.2011 16:18 The array size may be smaller than the number of students ( not teams) . Mine set at 400 why? n<=100 => max=100*3=300 | 0.5 sec | MOPDOBOPOT (USU) | 1837. Число Исенбаева | 16 ноя 2011 20:13 | 1 | 0.5 sec MOPDOBOPOT (USU) 16 ноя 2011 20:13 | WA 14 | hatred | 1837. Число Исенбаева | 24 окт 2011 04:18 | 3 | WA 14 hatred 11 авг 2011 02:51 Please give me test for Wa 14 Okay, I found my stupid mistake. May be it will help somebody: ensure that your MAX_K constant 300, not 100, where K is a number of participants (not a number of commands) Thanks, it was my fucking same mistake, :O | why WA #5 give me some tests | 219 | 1837. Число Исенбаева | 20 окт 2011 21:21 | 1 | #include <iostream> #include <string.h> using namespace std; int orni[10000]={-1},ornini; char a[]="Isenbaev"; int main() {
int n,i,k,l,q,qator[500]={0},s,j,r,r1,r2; bool f=0; char ism[10000][30],ismi[500][4][30],soz[30]; cin>>n; for(i=1;i<=n;i++) for(j=1;j<=3;j++){cin>>ismi[i][j]; if(f==0&&strcmp(ismi[i][j],a)==0){f=1;r1=i;r2=j;}}
// agar Isenbaev bo'lsa tekshiriladi; if(f==1) { // cout<<1<<endl; strcpy(soz,ismi[r1][r2]); strcpy(ismi[r1][r2],ismi[1][1]); strcpy(ismi[1][1],soz);j=2; for(i=1;i<=3;i++) { if(i!=r2) { strcpy(soz,ismi[r1][i]); strcpy(ismi[r1][i],ismi[1][j]); strcpy(ismi[1][j],soz); j++; } } orni[0]=0; strcpy(ism[0],ismi[1][1]); //ism[0]=ismi[1][1]; l=0; for(k=0;k<=l;k++){ for (i=1;i<=n;i++) { for(j=1;j<=3;j++) if (qator[i]==0&&strcmp(ism[k],ismi[i][j])==0) { for(q=1;q<=3;q++) { s=true; strcpy(soz,ismi[i][q]);
for(r=0;r<=l;r++) { if(strcmp(ism[r],soz)==0)s=false; } if(s){l=l+1;strcpy(ism[l],soz); orni[l]=orni[k]+1;}
} qator[i]=1; } }} for(i=1;i<=n;i++) { if(qator[i]==0) { for(j=1;j<=3;j++) { s=true; strcpy(soz,ismi[i][j]); for(k=0;k<=l;k++) { if(strcmp(ism[k],soz)==0)s=false; } if(s){l=l+1;strcpy(ism[l],soz);orni[l]=-1;} } } }
}
// Isenbaev bo'lmasa ko'rib chiqamiz;
else { l=-1; for(i=1;i<=n;i++) {
for(j=1;j<=3;j++) { s=true; strcpy(soz,ismi[i][j]); for(k=0;k<=l;k++) { if(strcmp(ism[k],soz)==0)s=false; } if(s){l=l+1;strcpy(ism[l],soz);orni[l]=-1;} }
}
} for(i=1;i<=l;i++) { j=i; while(j>0&&strcmp(ism[j],ism[j-1])<0) {
strcpy(soz,ism[j]); ornini=orni[j]; strcpy(ism[j],ism[j-1]);orni[j]=orni[j-1]; strcpy(ism[j-1],soz);orni[j-1]=ornini; j--; } } for(i=0;i<=l;i++){cout<<ism[i]<<" ";if(orni[i]!=-1)cout<<orni[i]; else cout<<"undefined"; cout<<endl;}
return 0; } | WA #7 | Meir | 1837. Число Исенбаева | 22 авг 2011 17:06 | 1 | WA #7 Meir 22 авг 2011 17:06 Hi there! I have a "Wrong answer" result on test #7. Can anyone please advise a test #7? Thanks. | WA #3 | dima11221122 | 1837. Число Исенбаева | 11 авг 2011 01:09 | 6 | WA #3 dima11221122 30 апр 2011 15:13 A undefined B undefined C undefined Re: WA #3 Smilodon_am [Obninsk INPE] 3 май 2011 11:41 Try always this inverted test: 1 C B A Answer is the same: A undefined B undefined C undefined Hmm, my prog passes these tests, but gets WA3. Plz give more tests | WA#4 | Vladimir (BSTU_VOENMEH) | 1837. Число Исенбаева | 31 июл 2011 16:26 | 1 | WA#4 Vladimir (BSTU_VOENMEH) 31 июл 2011 16:26 | test3 Crash (access violation) | pphzr | 1837. Число Исенбаева | 6 июл 2011 10:25 | 1 | | Original - Erdos number =) | Vedernikoff 'Goryinyich' Sergey (HSE: АОП) | 1837. Число Исенбаева | 28 июн 2011 15:58 | 1 | | why WA 9 test? help | Charm | 1837. Число Исенбаева | 28 июн 2011 15:12 | 1 | |
|
|