Common BoardI tried all test cases which were written in the discussion part and my program gives the correct answer for all of them. How to find my error: #include <bits/stdc++.h> using namespace std; #define pb push_back #define endl "\n" /*DELETE IT ON INTERACTIVES!!*/ #define mod 1000000007 #define int long long #define double long double #define all(x) x.begin(), x.end() const int N = 1e3+5; vector<int> adj[N],marked(N,0),killed(N,0),vis_1(N,0),torun(N,1),vis_2(N,0); int ok; void dfs(int node){ vis_1[node] = 1; if(killed[node]) ok = 1; for(auto go : adj[node]){ if(!vis_1[go]){ dfs(go); } } } void mark(int node){ marked[node] = 1; vis_2[node] = 1; for(auto go : adj[node]){ if(!vis_2[go]){ mark(go); } } } void solve(){
int n; cin>>n; string s,t; while(cin>>s){ if(s == "BLOOD") break; cin>>t; adj[(int)s[0] - '0'].pb((int)t[0] - '0'); torun[(int)t[0] - '0'] = 0; } int a; while(cin>>a){ killed[a] = 1; } for(int i=1;i<=n;i++){ if(torun[i]){ dfs(i); if(ok){ mark(i); } fill(all(vis_1),0); fill(all(vis_2),0); ok = 0; } } int hehe = 0; for(int i=1;i<=n;i++){ if(!marked[i]){ hehe = 1; cout<<i<<' '; } } if(!hehe) cout<<0; } int32_t main(){
cin.tie(0); ios::sync_with_stdio(0); int t=1; //cin>>t;
while(t--) solve();
return 0; } 5 1 2 3 4 5 shold be 4 1 1 2 3 4 5 (or others) but can't be 5 0 1 2 3 4 5 What if one of them is outside the trap? Do they still need to keep contact (have at least one common corner)? Edited by author 20.10.2012 18:13 Yes, what's the answer for this test: 1 2 +.+-+ |1|2. +-+-+ ? UPD: i got accepted, answer for this test is 2. Too bad it doesn't clarify anything about original question, so I'll answer it: yes, they have to be in adjacent rooms even after one of them got out. Edited by author 23.10.2012 23:34 So the first one out must remain in contact with the other, but if the other can step out on the very next turn, and by stepping out they become separated, it's OK...? In my solution what you said is not allowed, but it seems like in optimal solution this situation can't happen. > In my solution what you said is not allowed Then shouldn't the answer to your example be 3 instead of 2 as your wrote? 1 up 1 right 2 right Your answer of 2 requires: 1 up 2 right But this separates them. Edited by author 25.10.2012 11:25 Yes, but there are no walls outside the given rectangle, so while executing "1 right" command you don't pass through thin wall and thus the answer isn't increased ;D Doh. Right you are. I did not read the problem statement properly. I was thinking it was "number of moves." I think yes.Because I got WA5 if no.But AC if yes. My English is very bad.Sorry. a is the number of NO ; b is the number of YES ans=a/n+(n-1)*(a/n)*(b/(n-1))+(n-1)*(b/n)*(a/(n-1)) =a/n+2ab/n =a*(1+2b)/n O(W*H) solution passes Edited by author 22.08.2021 13:50 Edited by author 22.08.2021 13:50 "чтобы любой отрезок пути длиной k километров пробегать ровно за h часов." Если ЛЮБОЙ отрезок длины к он пробегает за h, то разве из этого не следует, что скорость постоянна? Ну бежал от 99% пути со скоростью света А оставшийся 1% пути пробежал с такой скоростью (очень медленно пробежал) , чтобы получить суммарное время h часов Странность здесь в другом: какой может быть максимум времени, если не оговорены ограничения на траекторию поездки ?! Он ведь может кататься зигзагами, потерять в дороге паспорт и прочесывать тундру в его поисках, и т.п. Максимум равен бесконечности ! Edited by author 27.09.2018 01:21 Полностью согласен. Условие задачи явно кривое. Скорость оленей не ограничена, т.е. они могут хоть телепортироваться считай Здесь факт лишь в том, что они должны пробежать за H часов K километров По этому минимальное например при данных 30 11 2 будет равно 4 Объясняю: За 4 часа олени пробегут 22 км (ну, 11*2 просто) , и так как осталось 8 км, то они могут это расстояние просто перелететь (телепортнуться), ведь это меньше 11 км, поэтому им и время не нужно (они же не прошли 11, значит и 2 часа не нужно). А с максимальным все очень просто, это просто время если бы олени двигались с постоянной скоростью, но могли немного перебежать нужное расстояние(главное чтобы оно было не больше к) При 30 11 2 макс время будет 6 часов, тк только тогда олени достигнут своих 30км изначальных (ну немного больше пробегут - 33 км) Надеюсь кому-то поможет в решение Спасибо) The problem is just from Russia. Pay attention, the Chukchi is running, not an Eskimo, not an Indian, but a Chukchi. And in Russia everything is relative. And the position of the Chukchi is relative. That is, the Chukchi is located somewhere in the Yamal-Nenets district. On the territory within a radius of 100 kilometers from the telephone tower. In 2 hours he will be in an area within a radius of 100 kilometers from another telephone tower. That is, he will reach Moscow in 4 hours, plus or minus 2 hours. Something like this. Translation problems. Что-то ваши объяснения не очень логичны. Вы уверены, что именно эта логика заложена авторами задачи ? use the formula sqrt(abs(x1 - x2)**2 + abs(y1 - y2)**2) not abs(x1 - x2) + abs(y1 - y2) Please give me some tests! (Please forgive me for my poor English.) First,use Hash to record ai Then,enumerate i,j as the first and the second items in the arithmetic sequence.check if 2*a[i]-a[j] exists.If it exists,we stop it immediately because the arithmetic sequence has been found.Otherwise,we find the arithmetic as brute force and mark the longest arithmetic sequence. At last,it's easy to restore the arithmetic sequence. So we can solve it in O(n^2). Edited by author 20.08.2021 13:43 Give some tests, please I hope, the following will help. I've found it using a random generator and a brute force checker. 7 2 -5 -4 -1 -1 -5 5 Answer: 13 In this problem, all the operations should be done on the SAME computer, but I could NOT understand this from the statement, until I read the forum. This problem is quite easy: simple bruteforce could AC in short time, but I think this bug in statement have made this problem SEEMS hard (only 100+ ACed now). Please, fix it. I think you can do on every computers.But doing on the same computer is the best solution. Maybe. Sorry my bad English.:) Damn, i used min(xa, xb) <= x_h <= max(xa, xb) and got WA5, then I wrote min(xa, xb) <= x_h && x_h <= max(xa, xb) and got AC Similar to page scheduling. Used two sets to simulate the process. :) Getting WA #9. My solution is bruteforce after dividing the lines give me some tests thanks. INPUT 1 2 1 0 1 1 0 1 0 OUTPUT 0 is correct? My AC program says 0 is correct!) The problem can be solved using brute force solution Make difference array, where dif[i] = i - a[i] |
|