Show all threads Hide all threads Show all messages Hide all messages |
C: Whats wrong with task? | Nick | 1001. Reverse Root | 22 Mar 2019 07:43 | 2 |
I've created file with tests, it seems all checks passes locally, but not in Judge here is my code: #include <stdio.h> #include <stdlib.h> #include <math.h> typedef struct list_node{ long int number; struct list_node * previous; } list_node_t; list_node_t * create_root(long int number); list_node_t * create_list(long int number, list_node_t * previous); int main() { long int a; list_node_t * current = NULL; while (scanf("%ld", &a) != EOF) { if (current == NULL) { current = create_root(a); } else { current = create_list(a, current); } } while (current != NULL) { printf("%.4Lf\n\r", sqrtl(current->number)); current = current->previous; } return 0; } list_node_t * create_root(long int number) { list_node_t *lt = malloc(sizeof(list_node_t)); lt->number = number; lt->previous = NULL; return lt; } list_node_t * create_list(long int number, list_node_t * previous) { list_node_t *lt = create_root(number); lt->previous = previous; return lt; } the problem is just calculate the square root in reverse order, it is unnecesary create a linked list or use pointer |
easy cpp solution | holykatty | 2023. Donald is a postman | 21 Mar 2019 23:27 | 1 |
#include <iostream> #include <vector> #include <string> using namespace std; int box(char a) { switch (a) { case 'A': case 'P': case 'O': case 'R': return 1; case 'B': case 'M': case 'S': return 2; default: return 3; } } int main() { int n; cin >> n; string a; vector<char>f(n); for (int i = 0; i < n; i++) { cin >> a; f[i] = a[0]; } int steps = 0; int pos = 1; for (int i = 0; i < n; i++) { steps += abs(pos - box(f[i])); pos = box(f[i]); } cout << steps << endl;
return 0; } |
ez problem c++ accept too easy lolololololllol solved 1 sec | RinchinGaY | 1878. Rubinchik's Cube | 20 Mar 2019 19:16 | 1 |
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <unordered_map> #include <map> #include <string> using namespace std; int main() { vector<vector<int>> v(4, vector<int>(4)); vector<int> col(4); for(int i= 0 ; i < 4; i++) { for(int j = 0; j < 4; j++) { cin >> v[i][j]; if(v[i][j] == 1) { if(((i == 0 || i == 1) && ((j == 0) || (j == 1)))) { col[0]++; } else if((i == 0 || i == 1) && ((j == 2) || (j == 3))) { col[1]++; } else if((i == 2 || i == 3) && (j == 0 || j == 1)) { col[2]++; } else { col[3]++; } } } } cout << min(min(col[1] + col[2] + col[3] + col[3], col[2] + col[0] + col[2] + col[3]), min(col[1] + col[2] + col[0] + col[0], col[0] + col[3] + col[1] + col[1]));
} |
What is a correct boolean expression? | LX&R Bacherikov | 1101. Robot in the Field | 19 Mar 2019 03:46 | 2 |
Here is the right description: 1) A, ..., Z, TRUE, FALSE - are correct boolean expressions; 2) if x and y are correct boolean expressions, then the correct boolean expressions are also: (x); NOT x; x AND y; x OR y (maybe, with some extra spaces). Edited by author 19.09.2007 23:19 It's not completely true, some spaces also may be missed as in example. |
WA#17 Help, please | Ann | 1227. Rally Championship | 19 Mar 2019 00:15 | 1 |
An example from other discussions: input: 4 3 12 1 2 5 1 3 4 3 4 4 output: YES displays the correct answer. Tell me more examples, please. In the algorithm, I check loops, two-way roads, cycles, and then look for a way longer than necessary. UPD: WA#18 Edited by author 20.03.2019 19:17 |
TLE #42 | Mirjalol Bahodirov | 1915. Titan Ruins: Reconstruction of Bygones | 18 Mar 2019 22:29 | 3 |
TLE #42 Mirjalol Bahodirov 23 Dec 2015 02:44 Thank you for your advice! I used BufferedInputStream/BufferedOutputStream and that gave me a great boost (from 0.98 to 0.156)! in c++ use ios_base::sync_with_stdio(0); |
В чем прикол? | AdiZer0 | 1296. Hyperjump | 18 Mar 2019 18:40 | 2 |
Я написал рекурсию которая каждый раз делила отрезок на два и брала максимальный среди ответа всех таких отрезков которых поделила.(типо Merge Sort). У меня был memory limit на 3 тесте. Это значить рекурсия берет память? Да, берёт. Рекурсия хранит итерации в стеке. |
WA TEST #6. | Jumabek Alikhanov | 2020. Traffic Jam in Flower Town | 18 Mar 2019 12:32 | 2 |
Can anyone give me some clue please? Re: WA TEST #6. George_Aloyan[PTS_Obninsk][MIPT_DPQE][MIPT_PSEPMS][IPG] 18 Mar 2019 12:32 Try this test: LFR FLR Ans should be 4, not 5 |
python ez solution | fatnet | 1585. Penguins | 17 Mar 2019 12:18 | 1 |
n = int(input()) d = {} for i in range(n): s = input() if s not in d: d[s] = 0 d[s] += 1 ans = sorted(d.items(), key=lambda kv: kv[1])[-1][0] print(ans) |
1 | Goergiy | 1079. Maximum | 17 Mar 2019 12:09 | 1 |
1 Goergiy 17 Mar 2019 12:09 |
easy MST | amomorning | 1982. Electrification Plan | 17 Mar 2019 10:42 | 2 |
use prim or kruskal can solve it. |
WA on 6. Can anyone tell me why? | raphaelrbr | 1671. Anansi's Cobweb | 17 Mar 2019 04:29 | 1 |
#include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second #define mp make_pair #define pii pair<int,int> #define vi vector<int> #define pq priority_queue #define pb push_back #define watch(x) cout << (#x) << " is " << (x) << endl #define ALL(a) (a.begin()),(a.end()) #define FOR(x,to) for(x=0;x<(to);x++) #define FORI(a,b) for(int i = a; i<b; i++) #define fastio ios::sync_with_stdio(0); cin.tie(NULL); const int INF = 0x3f3f3f3f; struct ar{ ll x,y; }; ar v[100100]; int p[100100] = {0}; ll id[100100]; ll sz[100100]; ll num; ll find(ll x){ if(id[x] == x) return x; return id[x] = find(id[x]); } void join(ll x, ll y){ ll p = find(x); ll q = find(y); if(p==q) return; num--; if(sz[p] > sz[q]) { ll t = q; p = q; q = t; } id[p] = q; sz[p] += sz[q]; } int main(){ fastio ll n,m,i,q; cin >> n >> m; num = n; ll arf[100100]; ll ans[100100];
FOR(i,m){ cin >> v[i+1].x >> v[i+1].y; } FOR(i,m+1){ id[i+1] = i+1; sz[i+1] = 1; } cin >> q; FOR(i,q){ ll x; cin >> x; p[x] = 1; arf[q-i] = x; } FOR(i,m+1){ if(i==0) continue; if(!p[i]){ join(v[i].x, v[i].y); } }
ans[q] = num; for(int i = 1; i<=q; i++){ join(v[arf[i]].x, v[arf[i]].y);
ans[q-i] = num;
}
for(int i = 1; i<=q; i++){ cout << ans[i] << " "; }
cout << "\n"; return 0; }
Edited by author 17.03.2019 04:30 |
что не так с кодом? | Demorald | 1001. Reverse Root | 17 Mar 2019 04:01 | 1 |
#include <iostream>; #include <vector>; #include <string>; #include <sstream>; #include <iomanip> using namespace std; int main() { int temp; vector <double> answers; string s; getline(cin, s); istringstream iss(s); while (iss >> temp) { double a = sqrt(temp); answers.push_back(a); } for (int i = answers.size(); i > 0; i--) { cout << fixed << setprecision(4) << answers[i-1]; cout << endl; }
system("pause"); return 0; } |
Runtime error Test #6 (ノ-_-)ノ彡┻━┻ | netufantazii | 1123. Salary | 15 Mar 2019 22:09 | 1 |
sorry, I'm just an idiot... Edited by author 27.03.2019 22:39 |
3 test!!! | Julia | 2035. Another Dress Rehearsal | 15 Mar 2019 12:34 | 1 |
|
WA#3 | VladimirZagorodskih | 1020. Rope | 15 Mar 2019 02:18 | 5 |
WA#3 VladimirZagorodskih 28 Feb 2010 10:57 I couldn't understand my mistake! On my tests it works correct. program project1; var n, i : longint; r, res, x, y, x1, y1, x0, y0 : extended; begin {$IFNDEF ONLINE_JUDGE} assign(input, 'input.txt'); assign(output, 'output.txt'); reset(input); rewrite(output); {$ENDIF} readln(n, r); readln(x, y); x0:=x; y0:=y; res:=2*pi*r; for i:=1 to n-1 do begin readln(x1, y1); res:=res+sqrt(sqr(x1-x)+sqr(y1-y)); y:=y1; x:=x1; end; res:=trunc(res*100)/100; write((res+sqrt(sqr(x1-x0)+sqr(y1-y0))):1:2); {$IFNDEF ONLINE_JUDGE} close(input); close(output); {$ENDIF} end. Re: WA#3 Petrova Valentina [USU] 3 Mar 2011 23:46 I've got the same problem=) May be there is a mistake with counting doubles (extended) and printing the answer... I suppose Edited by author 03.03.2011 23:46 Edited by author 03.03.2011 23:47 On the test 3 n=1, so you need to print the perimeter of nail. Good luck Re: WA#3 Mehedi Imam Shafi 26 Sep 2016 10:51 On the test 3 n=1, so you need to print the perimeter of nail. Good luck thanks helped Re: WA#3 Mozammal Hossain 15 Mar 2019 02:18 for n=1,r=1. What will be the answer? is there any effect on axes position? |
??? | Search | 1607. Taxi | 12 Mar 2019 23:15 | 13 |
??? Search 2 Mar 2008 01:06 Please help me.I always have WA#4. Give me any tests. THAnk!!!>< Try this: 1) 100 100 150 20 Answer is 150 2) 100 100 50 20 Answer is 100 Now I've WA#14.Please give some new tests.Thank!!! Edited by author 03.03.2008 20:06 denton> Thanks for the first test. It really helped me!!! Re: ??? Plamen_Iliev 5 Apr 2008 19:36 I think the answer is 200!!! wrong Velea Alex 29 Dec 2008 22:57 Posted by denton March 02, 2008 15:11 Try this: 1) 100 100 150 20 Answer is 150 2) 100 100 50 20 Answer is 100 re:::: at test 2 the answer is 50 becouse the taxi driver ofer him 50 and in less then 100 :D Edited by author 29.12.2008 22:58 Edited by author 29.12.2008 22:58 You are wrong, 'cause first turn is Petr and after that the turn of driver, but I think driver wasn't stupid one and he would not offer Petr smoller summ. Re: wrong Bahodir | {TUIT} | 29 Nov 2014 17:24 Accepted Test: 3 3 5 2 5 Edited by author 29.11.2014 20:35 thanks a lot, your tests helped me Hi, I have issue with the case "100 100 50 20"... Because logically the drivers shouldnt ask a price < price offer from Peter.. Re: ??? gunfighter 12 Mar 2019 23:15 thanks for the test, helped to get AC after WA#4 Edited by author 12.03.2019 23:16 Re: ??? Bahodir | {TUIT} | 29 Nov 2014 17:07 Inpt : 1 2 12 3 Output : 5 1 2 12 3 answer 6 Edited by author 12.12.2018 21:22 |
Who knows what is the test 7? | David Yin | 1005. Stone Pile | 12 Mar 2019 20:15 | 4 |
Who knows what is the test 7? I failed at this test. [code deleted] Edited by moderator 29.01.2022 18:45 6 1 2 3 4 100 100 Will fail this program The solution is not correct |
AC hint | gdh | 1234. Bricks | 12 Mar 2019 18:47 | 2 |
Problem should have weak tests if you got AC xD |
Tests and Answers | Felix_Mate | 1984. Dummy Guy | 12 Mar 2019 00:04 | 2 |
for n:=1 to 50 do : 1 2 2.15470053837925 2.41421356237309 2.70130161670408 3 3.30476487096249 3.61312592975275 3.92380440016309 4.23606797749979 4.54946553288422 4.86370330515627 5.17858146886038 5.49395920743493 5.80973434474413 6.12583089548301 6.44219115175181 6.75877048314363 7.07553382097426 7.39245322149966 7.7095061398084 8.02667418333227 8.34394219610391 8.66129757554039 8.97872975555948 9.29622981055875 9.61379014847791 9.93140427038051 10.2490665803026 10.5667722335056 10.8845170143696 11.2022972373783 11.520109666252 11.8379514474594 12.155820055209 12.4737132456699 12.7916290186635 13.109565585441 13.4275213414455 13.7454948431824 14.0634847884921 14.3814899996548 14.6995094088628 15.0175420456841 15.3355870262037 15.6536435435869 15.9717108598527 16.2897882986785 16.6078752390897 16.9259711099087 pi = 3.14159265; alf = (n - 2) * 180 / (2 * n); ans = 1. + 1. / cos((alf * pi) / 180); cout << ans; |