| Show all threads Hide all threads Show all messages Hide all messages |
| what???? | Sprint_me | | 4 Apr 2019 21:14 | 1 |
konec = int(input()) spisok = [] i=1 if konec <0: while i>=konec: spisok.append(i) i-=1 else: while i<=konec: spisok.append(i) i+=1 print(spisok) print(sum(spisok)) |
| If you have WA #3 | german_goncharov | 1654. Cipher Message | 2 Apr 2019 03:53 | 1 |
For test you can use this string: hkjgnnngkikipipekkfkfgg Correct result is: hkjgngkikipipefkf |
| how to make faster? | TSU_TheScull | 1654. Cipher Message | 2 Apr 2019 03:05 | 1 |
using System; namespace pain { class Program { static void Main(string[] args) { string s = Console.ReadLine(); char[] ss = new char[s.Length]; for (int i = 0; i < s.Length; i++) ss[i] = s[i]; for (int i = 0; i < s.Length - 1;) { if (ss[i] == ss[i + 1]) { if (i - 1 >= 0) { int n = i + 2; b: if (n <= s.Length - 1) { if (ss[n] != ' ') { ss[i] = ss[n]; ss[n] = ' '; ss[i + 1] = ' '; } else { n++; goto b; } } else break; } else { ss[i] = ' '; ss[i + 1] = ' '; } if (i >= 1) i--; else i++; } else i++; } for (int i = 0; i < s.Length; i++) if(ss[i] != ' ') Console.Write(ss[i]); //Console.Write(st2(s)); Console.ReadLine(); } public static string st1(string s, ref int n) { if (s.Length - 1 > n) { if (s[n] == s[n + 1]) { s = s.Remove(n, 2); if (n >= 2) n -= 2; else n--; } n++; s = st1(s, ref n); } return s; } public static string st2(string s) { for (int i = 0; i < s.Length - 1; i++) { if (s[i] == s[i + 1]) { s = s.Remove(i, 2); if (i >= 2) i -= 2; } } return s; } public static string st3(string s) { int n = 0; int nt = s.Length - 1; string[] ss = new string[nt]; for (int i = 0; i < nt; i++) { bool d = false; for (int j = i; j < nt; j++) { if (ss[i] == s[j].ToString()) { d = true; } } if (!d) { ss[n] = s[i].ToString(); n++; } } n = 0; while (nt != 0) { nt = s.Length; for (int i = 0; i < ss.Length; i++) { s = s.Replace(ss[i] + ss[i], ""); } if (nt == s.Length) break; } return s; } } } Edited by author 02.04.2019 03:06 |
| Offtopic | Korobov | 1220. Stacks | 30 Mar 2019 14:21 | 3 |
Yeah! I did it! I spent about 4 hours to solve this problem =) |
| Limit is too small | Radu Berinde | 1110. Power | 28 Mar 2019 19:39 | 4 |
The problem limits are too small. You can get ac with the O(N^2) algorithm which is VERY straightforward. The limit should force you to use the O (log N) algorithm to compute X^N (%M) > The problem limits are too small. > You can get ac with the O(N^2) algorithm which is VERY > straightforward. The limit should force you to use the O > (log N) algorithm to compute X^N (%M) O(log N) !? Isn't it O(MlogN) ? well,if it's really O(log N) , please tell me how :) I got AC with 0.031 373 KB using brute force. This is the dummest task I made. Tell them to read the O(M log N) algorith in Introduction in algo(Coreman) This sadly is my AC source: var i,j,k,l,m,n:longint; ok:boolean; begin readln(n,m,k); for i:=0 to m-1 do begin l:=i; for j:=1 to n-1 do l:=(l*i) mod m; if l mod m=k then begin write(i,' '); ok:=true; end; end; if not ok then write(-1); end. Edited by author 10.05.2004 17:49 Hello, explain to me why you use l:=(l*i) mod m;(...mod m)?!! Why? |
| solved on python | blonded | 2102. Michael and Cryptography | 28 Mar 2019 18:12 | 1 |
0.436 seconds, 6840 kb just go to google and type there: monte carlo factorization --- this algo is O(N^1/4), so its O(1e4 * sqrt(2)) |
| Hint! | basuki | 1837. Isenbaev's Number | 27 Mar 2019 21:45 | 1 |
Hint! basuki 27 Mar 2019 21:45 |
| Test 19 | Smilodon_am [Obninsk INPE] | 1769. Old Ural Legend | 26 Mar 2019 16:17 | 2 |
Test 19 Smilodon_am [Obninsk INPE] 30 Mar 2012 12:35 This test contain such string that answer (minimal integer number) is more than 99999. |
| some tests for wa7 | 🦄imosk72🦄[GTGU] | 1532. Lost in Translation | 23 Mar 2019 20:29 | 1 |
2 jsesi jesfi 2 tvtx vtix 2 qfqejjfhrhono fqwejjfhrhono 2 mciqibekphze mcqibmekphze 2 affjoromdta affjromjdta all answers should contain both strings |
| 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 | kphtsv | 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? | Al.Cash | 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); |
| 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][IPG][ALIGN][YANDEX] 18 Mar 2019 12:32 Try this test: LFR FLR Ans should be 4, not 5 |
| python ez solution | blonded | 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 | Arseniyy | 1079. Maximum | 17 Mar 2019 12:09 | 1 |
1 Arseniyy 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 |