| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| few hints | SButterfly | 1413. Марсопрыг | 30 окт 2014 01:28 | 1 |
Don't update current x and y on each iteration. Save the total number of jumps of one direction. Ex: int toSouthWest = 0; for (int i = 0; i < a.legth; i++) { if (a[i] == '1'){ toSouthWest++; } if (a[i] == '9'){ toSouthWest--; } if (a[i] == '8'){ toSouth++ } ... } then you sum diractions vectors and get the answer double y = toSouth + (toSouthWest + toSouthEast)*(1/2)^(1/2); double x = ... good luck!! |
| what is wrong in my code (WA №2)? | Alexandr Zhelanov | 1025. Демократия в опасности | 29 окт 2014 14:42 | 4 |
What is wrong in my code? Please, give me a hint. var k,i,min,max,voices,sum:integer; ka:array [1..101] of integer; begin readln(k); for i:= 1 to k do begin read(ka[i]); if i=1 then begin min:=ka[i]; max:=ka[i]; end else begin if ka[i]<min then min:=ka[i]; if ka[i]>max then max:=ka[i]; end; end;
if min<>max then begin for i:=1 to k do begin if ka[i]=min then sum:=sum+ka[i]; end; voices:=sum div 2 +1; end else begin for i:=1 to k do sum:=sum+ka[i]; voices:=sum div 2 +1; end;
writeln(voices); end. |
| TO ADMINS | bsu.mmf.team | 2027. URCAPL, эпизод 1 | 28 окт 2014 21:45 | 1 |
My AC programm return "TIME LIMIT EXCEEDED" for such tests(cycle with path throw '.' in different direction): 4 4 ..v. >..# .... ^.<. 1 1 |
| WA #8 | Snayde | 1901. Космический лифт | 28 окт 2014 13:23 | 3 |
WA #8 Snayde 7 май 2013 13:56 Try this: 6 15 6 10 6 9 7 1 I think your answer is: 4 6 10 6 9 7 1 But answer like: 5 6 10 7 9 6 1 Re: WA #8 quick(YaroslavlSU) 28 окт 2014 13:23 5 22 8 15 6 6 14 answer 4 8 15 14 6 6 |
| how to get user input with out compiling the Java...PLZ urgent | Farruh | 1001. Обратный корень | 28 окт 2014 08:34 | 2 |
I can get user input ...coz when i wanna make the line breaks...Java compiler Intillej starts to get compiled plz i need help to get input use this code ********************************* char[] bytes = new char[256 * 1024]; BufferedInputStream bufferedInputStream = new BufferedInputStream(System.in); InputStreamReader inputStreamReader = new InputStreamReader(bufferedInputStream); inputStreamReader.read(bytes); String string = new String(bytes); |
| TO ADMINS | bsu.mmf.team | 2032. Теория заговора и ребрендинг | 28 окт 2014 00:17 | 2 |
There are all the numbers are greater than 1000000 in the test 6! Please remove this test or fix the description of the problem. P.S. After I discovered it I solved the problem anyway :) Thank you! Russian and English statements had different constraints. Now both have 10^7 for input lengths. |
| 1396 Maximum. Version 2, help me !!! | bitagi | | 27 окт 2014 21:20 | 1 |
I have no solution to this problem, help me |
| c | durgesh pandey | 1009. K-ичные числа | 27 окт 2014 14:26 | 1 |
c durgesh pandey 27 окт 2014 14:26 Edited by author 27.10.2014 14:27 |
| WA #9 | mikhsatyshev | 2033. Девайсы | 26 окт 2014 07:40 | 1 |
WA #9 mikhsatyshev 26 окт 2014 07:40 What's wrong? Here is my solution: var i,j,k,y,fl,s,t,max,min,r:longint; a:array [1..100] of string; b,c:array [1..100] of longint; d,x:string; begin for i:=1 to 6 do begin readln (d); readln (x); readln (y); fl:=0; for j:=1 to k do If a[j]=x then fl:=j; If fl=0 then begin k:=k+1; a[k]:=x; b[k]:=y; c[k]:=1;end; If fl>0 then If y<b[fl] then begin b[fl]:=y; c[fl]:=c[fl]+1;end else c[fl]:=c[fl]+1; end; max:=-2000000000; for i:=1 to k do if c[i]>max then max:=c[i]; for i:=1 to k do if c[i]=max then begin s:=s+1; r:=i;end; If s=1 then writeln (a[r]) else begin min:=2000000000; for i:=1 to k do If b[i]<min then min:=b[i]; i:=0; repeat i:=i+1; if b[i]=min then writeln (a[i]); until (b[i]=min) or (i=k); end; end. |
| Could you explain sample 1? | zsc_llc | 2027. URCAPL, эпизод 1 | 25 окт 2014 20:09 | 2 |
That's how the pointer moves: x = 0; y = 0 x = 1; y = 0 x = 2; y = 0 x = 3; y = 0 x = 3; y = 1 x = 4; y = 1 x = 4; y = 2 x = 4; y = 3 x = 3; y = 3 x = 2; y = 3 x = 1; y = 3 x = 0; y = 3 x = 0; y = 2 x = 0; y = 1 x = 1; y = 1 x = 2; y = 1 x = 3; y = 1 x = 4; y = 1 x = 4; y = 2 x = 4; y = 3 x = 3; y = 3 x = 2; y = 3 x = 1; y = 3 x = 0; y = 3 x = 0; y = 2 x = 0; y = 1 x = 1; y = 1 x = 2; y = 1 x = 3; y = 1 x = 4; y = 1 x = 4; y = 2 x = 4; y = 3 x = 3; y = 3 x = 2; y = 3 x = 1; y = 3 x = 0; y = 3 x = 0; y = 2 x = 0; y = 1 x = 1; y = 1 x = 2; y = 1 x = 3; y = 1 x = 4; y = 1 x = 4; y = 0 x = 5; y = 0 x = 5; y = 1 x = 5; y = 2 x = 5; y = 3 |
| give some tests | mamur91 | 1290. Саботаж | 25 окт 2014 17:07 | 1 |
hi I need some test to check my code it works ok when I enter numbers but not accepted in "test 2" |
| No subject | zhavohir | 2035. Очередной пробный тур | 25 окт 2014 15:23 | 1 |
Edited by author 25.10.2014 15:23 |
| No subject | Platt96 | 1083. Факториалы!!! | 24 окт 2014 17:23 | 2 |
Если k>n что будет выводить? |
| Try this test | Spatarel Dan Constantin | 2009. Очереди в столовой | 24 окт 2014 04:20 | 1 |
The following test helped me a lot: Input: 10 2 0 0 0 0 1 0 3 0 4 0 5 0 6 0 7 0 1 5 1 2 3 4 5 2 5 6 7 8 9 10 Output: 2 right 2 left 5 right 3 left 3 right 6 left 4 left 4 right 6 right 5 left |
| Test 22 Time limit exceeded! I need help | Egor14 | 1917. Руины титанов: убийственная точность | 24 окт 2014 00:23 | 1 |
Hi! I have time limit exceeded in test 22. What's wrong with my code? What is the best approach for this task? Maybe use stack? Thanks; My code: #include <iostream> #include <vector> #include <algorithm> using namespace std; //Get all possible spell power variants vector<int> GetVariants(vector<int> vct) { vector<int> answ; for(unsigned int i=0;i<vct.size();i++) { if(find(answ.begin(),answ.end(),vct[i])==answ.end()) answ.push_back(vct[i]); } sort(answ.begin(), answ.begin()+answ.size()); reverse(answ.begin(),answ.end()); return answ; } //Get number or values, in vct which <= num (here it is destructable coins) int GetNumberOfLowerOrEqual(vector<int> vct,int num) { int number = 0; for(unsigned int i=0;i<vct.size();i++) { if(vct[i]<=num)number++; } return number; } int main() { int n,p,curr; scanf("%d",&n);//initial size of coins vector scanf("%d",&p);// health vector<int> coins; vector<int> variants; int deleted = 0; int spells = 0; for(int i=0;i<n;i++) { scanf("%d",&curr); coins.push_back(curr); } variants = GetVariants(coins); bool dChanged = false;
for(int times = 0; times<n && !coins.empty();times++) { for(int i=0;i<variants.size() && !coins.empty();i++) { if(GetNumberOfLowerOrEqual(coins,variants[i])*variants[i]<=p)//surrvived { dChanged = false; //here we remove all elements from coins, which <= variants[i] for(int t=0;t<coins.size();t++) { if(coins[t] <= variants[i]) { coins.erase(coins.begin()+t); t--; deleted++; dChanged = true; } } if(dChanged) { spells++;//if anything changed, add spell break; } } } } printf("%d ", deleted); printf("%d",spells); //system("pause"); return 0; } |
| WA7 | armogirl | 1893. A380 | 23 окт 2014 20:02 | 5 |
WA7 armogirl 16 ноя 2012 01:46 sorry, didn't notice that the letter I is omitted!! )) Re: WA7 PlayLinsor 3 окт 2013 18:15 use correct alphabet A B C D E F G H K Re: WA7 IvanMetelev 23 окт 2014 20:02 |
| Wrong jury solution? (to admins) | Alexey Dergunov [Samara SAU] | 2021. Страшно интересно! | 22 окт 2014 13:21 | 3 |
I don't have permissons to this page. BTW, there was a bug in checker: std::unique wants sorted array. It's fixed on Timus. Thanks, I always forget about that sorting |
| Dynamic solution - help needed | Narek Aghekyan | 1501. Чувство прекрасного | 22 окт 2014 05:32 | 2 |
I want to use bool dp[N][N][3] array, where dp[i][j][0] is true if it is possible to solve the problem for last 'i' characters of string1 and for last 'j' characters of string2 and in current state it is necessary to take 0 and place into the stack of '0's. dp[i][j][1] is true if it is possible to solve the problem for last 'i' characters of string1 and for last 'j' characters of string2 and in current state it is necessary to take 1 and place into the stack of '1's. dp[i][j][2] is true if it is possible to solve the problem for last 'i' characters of string1 and for last 'j' characters of string2 and in current state stacks of '0's and '1's have the same size. Obviously (dp[N][N][2] == true) means that it is possible to solve the problem. My problem is that I can't fill this 3D array. Please help. you just need dp[i][j] and store there form were you get the last piece, if it was from 1 you can rebuild the path looking dp[i-1][j], if it was from 2 you llok dp[i][j-1]. If dp[i][j] = 0 you can't solve the problem. |
| Lang limit | MOPDOBOPOT (USU) | 1116. Кусочно-постоянная функция | 21 окт 2014 13:04 | 1 |
Is it possible to solve this problem with Python 3 or Scala? I got TLE with same linear algo on both langauges (tried mutable and immutable collections in Scala and so I think there are problems with slow input) but got AC (in 0.171 sec) only with pure Java solution. Edited by author 21.10.2014 13:07 |
| Using priority queue - getting WA#4. Why? | Stefan Dimov | 1022. Генеалогическое дерево | 21 окт 2014 11:00 | 2 |
I am using priority queue. Priority is determined by the number of elements. The top element is one without parents. When it's removed from the queue, it's being deleted as a parent from all the other elements. I get WA#4. Any idea why? This is my code. Can someone tell me why do I get WA#4? import java.util.Collection; import java.util.Comparator; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.PriorityQueue; import java.util.Scanner; public class MartianCouncil { public static void main(String[] args) { Hashtable<Integer, TreeNode> global = new Hashtable<Integer, TreeNode>(); Scanner s = new Scanner(System.in); int n = s.nextInt(); if (n == 0) { s.close(); return; } s.nextLine(); for (int i = 1; i <= n; i++) { TreeNode node = global.get(i); if (node == null) { node = new TreeNode(i); global.put(i, node); } String line = s.nextLine(); String[] nums = line.split(" "); for (int j = 0; j < nums.length - 1; j++) { int num = Integer.parseInt(nums[j]); TreeNode nd = global.get(num); if (nd == null) { nd = new TreeNode(num); global.put(num, nd); } node.addChild(nd); } } s.close(); print(global); }
public static void print(Hashtable<Integer, TreeNode> global) { PriorityQueue<TreeNode> q = new PriorityQueue<TreeNode>(); q.addAll(global.values()); StringBuilder res = new StringBuilder(""); while (!q.isEmpty()) { TreeNode nd = q.poll(); res = res.append((res.length() == 0) ? "" : " "); res = res.append(nd.getNum()); } System.out.print(res); }
public static class TreeNode implements Comparable<MartianCouncil.TreeNode> {
private int num = 0; private Collection<MartianCouncil.TreeNode> children = new HashSet<MartianCouncil.TreeNode>(); private Collection<MartianCouncil.TreeNode> parents = new HashSet<MartianCouncil.TreeNode>();
public TreeNode(int num) { this.num = num; }
public int hashCode() { return num; }
public boolean equals(Object o) { if (o == null) { return false; } else if (!(o instanceof MartianCouncil.TreeNode)) { return false; } else { return (this.hashCode() == o.hashCode()); } }
public boolean addChild(MartianCouncil.TreeNode child) { child.parents.add(this); return children.add(child); }
public boolean removeChild(MartianCouncil.TreeNode child) { child.parents.remove(this); return children.remove(child); }
public boolean addParent(TreeNode parent) { parent.children.add(this); return parents.add(parent); }
public boolean removeParent(TreeNode parent) { parent.children.remove(this); return parents.remove(parent); }
public void removeAllChildren() { Iterator<TreeNode> it = children.iterator(); while (it.hasNext()) { TreeNode child = it.next(); child.parents.remove(this); } children.clear(); }
public int getNum() { return num; }
public Collection<TreeNode> getChildren() { return children; }
public int getParentsNum() { return parents.size(); } @Override public int compareTo(MartianCouncil.TreeNode nd) { return Math.round(Math.signum(this.getParentsNum() - nd.getParentsNum())); } }
public class TreeNodeComp implements Comparator<MartianCouncil.TreeNode> { @Override public int compare(MartianCouncil.TreeNode nd1, MartianCouncil.TreeNode nd2) { return Math.round(Math.signum(nd1.getParentsNum() - nd2.getParentsNum())); } }
} |