| Show all threads Hide all threads Show all messages Hide all messages |
| AC in 0.09 ... a hint | Hristo Nikolaev (B&W) | 1726. Visits | 9 Apr 2023 18:52 | 3 |
After some failed attempts with O(n)=n*n/2, finally I found an O(n)=n solution. In plain C, it took 0.09s and 1.5Mb. (just from curiosity tried the same with C# - 14MB used RAM :)) The arrays of X and Y coordinates can be sorted independently from each other. So basically, this input: 3 1 3 2 1 3 2 will have exactly the same result (which is 2) as 3 1 1 2 2 3 3 Assuming a (x1, y1), b (x2, y2), then the distance from c (x3, y3) to (x1, y1) and (x2, y2) is equivalent to the distance from (x1, y2) and (x2, y1) |
| My bad | Evgeniy Park | 2145. Olympiad for Everyone | 6 Apr 2023 18:47 | 1 |
My bad Evgeniy Park 6 Apr 2023 18:47 My bad accepted, best Go solution to date Edited by author 06.04.2023 19:36 |
| If you have WA 48... | wery0 | 1075. Thread in a Space | 5 Apr 2023 10:58 | 1 |
Try this test: -10 -1 1 -1 8 1 -7 2 1 3 Answer: 14.38 |
| TLE 41 | Smetya | 2102. Michael and Cryptography | 2 Apr 2023 23:37 | 1 |
TLE 41 Smetya 2 Apr 2023 23:37 who has ideas, what test it is? |
| My PIBAS program has only 92 char | Ade | 1230. Introspective Program | 2 Apr 2023 16:00 | 1 |
|
| Test 23 | Daniial | 2102. Michael and Cryptography | 2 Apr 2023 15:57 | 2 |
Help please: Test 23, whats wrong, what test should chek? def sieve(n): lis = list(range(n + 1)) lis[1] = 0 for i in lis: if i > 1: for j in range(i + i, len(lis), i): lis[j] = 0 return [i for i in lis if i != 0] c = sieve(200) a = int(input()) if a == 0: print('No') i = 0 b = [] e = 0 while a != 1: if a%5 != 0 and a%2 != 0 and a%3 != 0: e +=1 break elif a % c[i] == 0: a /= c[i] b.append(c[i]) continue else: i += 1 d = str(len(b)) if len (b) == 20 or (len (b) == 19 and e != 0): print('Yes') else: print('No') In this code possible i > len(c) |
| hint for WA#2 | mengpq | 1423. String Tale | 31 Mar 2023 17:48 | 4 |
such data: 3 aaa aaa the answer is 0 rather than 3 I mean, it works, but the statement says that "If the problem has several solutions, you may output any of them". Obviously, 3 is the correct answer as well. So I guess it's test/statement problem? |
| Test for WA#5 | Pat | 1671. Anansi's Cobweb | 30 Mar 2023 13:07 | 1 |
5 8 2 3 1 2 2 5 1 4 1 5 3 4 3 4 4 4 8 7 6 8 2 3 4 5 1 > 1 1 1 1 2 3 4 5 |
| Idea | Hristo Nikolaev (B&W) | 1671. Anansi's Cobweb | 29 Mar 2023 21:04 | 1 |
Idea Hristo Nikolaev (B&W) 29 Mar 2023 21:04 Instead of doing the cuts in the order given in the input, I found it easier to do it in reverse order, so we get merging instead of cutting. Edited by author 29.03.2023 21:05 |
| I will just post the soution because i want to ruin it for you ;) | Ishan Pandey | 1930. Ivan's Car | 28 Mar 2023 23:19 | 3 |
#include<bits/stdc++.h> using namespace std; #define endl "\n" #define int long long #define mod 1000000007 #define maxn 10010 #define pb push_back #define mp make_pair #define fi first #define se second #define inf 100000000000 vector<pair<int, int>> adj[maxn]; int n, m; // struct node //for edges // { // int pos, dir, dist; // node(){}; // node(int _pos, int _dir) // { // pos = _pos; // dir = _dir; // } // }; int go(int s, int e) {
int dist[maxn][2]; for(int i=0; i<maxn; i++) { for(int j=0; j<=1; j++) { dist[i][j] = inf; } } deque<pair<int, int>> q; //pair->{node, edgedir} //making direction list here, q.push_back({s, 0}); //0->outgoing to node s dist[s][0] = 0; q.push_back({s, 1}); //1->incoming from node s dist[s][1] = 0; while(!q.empty()) { pair<int, int> cur = q.front(); //node int v = cur.first; int dir = cur.second; //dist int dv = dist[v][dir]; //guarenteed that shortest dist till cur node has been calc already q.pop_front(); //if(dv == inf) break;
if(cur.first == e) return dv; //gauarenteed via djikstra that this willbe minimest
//relax all the neighbours, and as you relax one , push into minheap the nodes for(auto it: adj[v]) { int to = it.fi; int dir2 = it.se; //previous //note that for type edge dir, you have relax for all neighbouring nodes int dist2=0; if(dir2 == dir) { dist2 = dist[v][dir2]; //dist[to][dir2] = min( dist[to][dir2], dist[v][dir2] ); } else dist2 = dist[v][dir] + 1; // dist[to][dir2] = min( dist[to][dir2], dist[v][dir] + 1);
//only relax and add to queue, if less than prev distance to this node if(dist2 < dist[to][dir2]) { if(dist2 <= dv) //less than equal to cur_dist q.push_front({to, dir2}); else q.push_back({to, dir2});
dist[to][dir2] = dist2;
}
} } return -1; } void solve() { cin>>n>>m; for(int i=1;i<=m;i++) { int x, y; cin>>x>>y; adj[x].pb({y, 0}); adj[y].pb({x, 1}); } int s, e; cin>>s>>e; //cout<<"hi"; int ans = go(s, e); cout<<ans<<endl; } signed main() { int t=1; //cin>>t; while(t--) { solve(); } return 0; } I do not understand the final push back and front part. Why to push only if dist is less than dv? Why are we comparing it to dv? If it is for the right position in the queue of the pushed element(like in 0-1 bfs),then how do we know that the queue only has 0-1? That is the underlying part of the 0-1 bfs right?else it is dijkstra. I think the queue has difference of 1 between its min and max. Can you tell what all is true and exactly what is happening. I would really appreciate. Thank you Edited by author 04.05.2020 20:46 Edited by author 04.05.2020 20:47 if(dist2 <= dv) //less than equal to cur_dist q.push_front({to, dir2}); else q.push_back({to, dir2}); CAN YOU EXPLAIN ME THIS PART WHY DIST 2 GREATER IS PUSHED BACK NOT IN FRONT AND VICE VERSA WHAT I MEAN TO KNOW IS WHY WE COMPARE CONNECTED VERTEX DISTANCE |
| I got AC! But i have question | __Andrewy__ | 1437. Gasoline Station | 28 Mar 2023 13:43 | 3 |
Я решил задачу с помощью графа, где вершинки - состояния ёмкостей,и рассмотрел из очередного состояния все переходы, запоминая те состояния ,где уже был. Но я никак не могу оценить кол-во возможных состояний. Может кто-нибудь подскажет как оценить? Самая грубая оценка - у нас есть числа a,b,c>=0 и a+b+c=N(для случая,когда не подливаем и не выливаем-в этом случае сумма константа). Тогда количество таких чисел O(N^3),но это ужасная оценка. Согласен, было бы интересно узнать максимальное количество возможных состояний и при каких значениях a,b,c оно достигается Edited by author 16.11.2019 13:00 Можно оценивать так: пусть ёмкости не превосходят значения C. Рассмотрим возможные переходы между состояниями. 1) Когда подливаем из заправки в канистру. Тогда канистра, в которую подливаем, становится полной. 2) Когда переливаем между канистрами. Тогда либо канистра, в которую переливаем, становится полной, либо канистра, из которой переливаем, становится пустой (либо и то, и то). Получается, что в каждом состоянии хотя бы одна канистра либо пустая, либо полная. Тогда количество состояний можно оценить как 6*(С+1)^2, то бишь O(C^2). |
| Please tell me what is the test 6? | lukamod | 1604. Country of Fools | 27 Mar 2023 22:09 | 1 |
|
| If you have WA #9 | Smilodon_am [Obninsk INPE] | 1982. Electrification Plan | 27 Mar 2023 17:15 | 7 |
First I used Kruskal algo but got WA9 verdict. My program didn't give right answer for next test: 4 1 4 0 1 1 100000 1 0 1 100000 1 1 0 100000 100000 100000 100000 0 right answer: 100002 Implementation of Prim algo gave the correct answer at last. HM, i have right output on this test, but WA 9 This test helped me.... 5 2 1 3 0 1 2 3 4 1 0 2 3 4 2 2 0 3 4 3 3 3 0 4 4 4 4 4 0 =8 (I was getting 9). Basically my algorithm (roughly Prim's) tried to short-cut checking vertex weights. For any node, make sure you check verices to ALL nodes.... HM, i have right output on this test, but WA 9 Some tests: 4 2 1 4 0 4 8 9 4 0 2 7 8 2 0 1 9 7 1 0 Answer 3 4 2 1 3 0 6 7 8 6 0 2 3 7 2 0 4 8 3 4 0 Answer 5 Edited by author 27.10.2015 20:10 5 3 1 3 2 0 1 2 3 4 1 0 2 3 4 2 2 0 3 4 3 3 3 0 4 4 4 4 4 0 answer is 7 Edited by author 19.02.2019 12:09 One more test that helped me to find my error for WA #9. 5 2 1 5 0 1 100 150 200 1 0 10 50 200 100 10 0 11 100 150 50 11 0 2 200 200 100 2 0 Answer: 13 c[i][j] = c[j][i] This is wrong test |
| if you have WA#10 try this: | hoan | 1542. Autocompletion | 26 Mar 2023 18:27 | 2 |
input: 2 b 1 a 1 2 a b output: a [empty] b hope can help you! GOOD LUCK! also, it has more than 10 matches |
| New tests added | Merkurev Oleg [Dandelion] | 1613. For Fans of Statistics | 24 Mar 2023 22:02 | 1 |
New tests were added. All accepted solution were rejudged, ~4% of them lost their accepted status |
| 2 lines programm, lol. It's not difficult at all | mmd18cury | 1582. Bookmakers | 24 Mar 2023 00:33 | 2 |
It can be at least 3 lines of code if you write one statement per line (in plain C) double k1, k2, k3; scanf("%lf %lf %lf", &k1, &k2, &k3); printf("%.0lf", /* The Expression */); Edited by author 24.03.2023 00:40 |
| ошибка в тесте 8 | Denison1023 [USU] | 1005. Stone Pile | 23 Mar 2023 19:59 | 3 |
не могу найти ошибку,возможно ли узнать какие числа вбивает 8-й тест? Только это называется не "ошибка в 8-м тесте" (сам тест корректен), а "ошибка *в решении* НА 8-м тесте". Тест - просто случайный тест, направленный на убивание жадных решений. Эту задачу неверно решать жадным алгоритмом. тест не случайный, так как при разных алгоритмах ошибки всегда под одними и теми же номерами |
| WA #2 | Pat | 1226. esreveR redrO | 21 Mar 2023 18:28 | 1 |
WA #2 Pat 21 Mar 2023 18:28 Check if your input correctly outputs the last word, if the last character is latin. The first test ends with a . Edited by author 21.03.2023 18:29 |
| is true? | Didi (OSU11) | 1997. Those are not the droids you're looking for | 21 Mar 2023 08:56 | 2 |
input: 6 3 8 1 0 2 0 3 0 4 0 5 1 7 1 10 1 12 1 output: No reason 1 10 2 5 3 12 4 7 |
| WA #3 | Iury Izotov FT-16 | 1080. Map Coloring | 21 Mar 2023 05:06 | 3 |
WA #3 Iury Izotov FT-16 26 Jun 2016 17:12 I dont know, but if you are using BFS in your solution, you should remember, that graph can contain more than 1 connected component. Try this test: 6 2 3 0 0 0 5 6 0 0 0 one of answers: 011100 тест неверный, по условию можно в любую страну перейти, а у вас например из 1 в 4 не перейти |