Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Maybe you did the same! | Tigoan Matei | 2056. Scholarship | 1 Jan 2020 17:00 | 1 | dont use ',' use '.' at 4.5 | | Sheer bliss! | Yermak | 1763. Expert Flea | 31 Dec 2019 18:39 | 6 | I did it! I figured out this formula! give any hint: F[n] = summa(a[i] * F[n-i], i=1..k) are right? (here a[i], and k - are consts). k=? a[]- easy generate, iff k - know. Yes, you are right. k = 19. Good luck! :-D (n-19>=7) start from 7... Hint: solve system equation with Gauss method (19x19). Edited by author 31.12.2019 16:33 static constexpr int results[] = { // 0 1 2 3 4 5 0, 0, 0, 0, 0, 0, /*Answer for n = 6 is*/ 12, /*Answer for n = 7 is*/ 46, /*Answer for n = 8 is*/ 144, /*Answer for n = 9 is*/ 110, /*Answer for n = 10 is*/ 312, /*Answer for n = 11 is*/ 290, /*Answer for n = 12 is*/ 670, /*Answer for n = 13 is*/ 706, /*Answer for n = 14 is*/ 1538, /*Answer for n = 15 is*/ 1732, /*Answer for n = 16 is*/ 3504, /*Answer for n = 17 is*/ 4288, /*Answer for n = 18 is*/ 8098, /*Answer for n = 19 is*/ 10568, /*Answer for n = 20 is*/ 19044, /*Answer for n = 21 is*/ 26042, /*Answer for n = 22 is*/ 45222, /*Answer for n = 23 is*/ 64220, /*Answer for n = 24 is*/ 108382, /*Answer for n = 25 is*/ 158324, /*Answer for n = 26 is*/ 261754, /*Answer for n = 27 is*/ 390314, /*Answer for n = 28 is*/ 635666, /*Answer for n = 29 is*/ 962282, /*Answer for n = 30 is*/ 1550244, /*Answer for n = 31 is*/ 2372372, /*Answer for n = 32 is*/ 3792560, /*Answer for n = 33 is*/ 5848746, /*Answer for n = 34 is*/ 9299148, /*Answer for n = 35 is*/ 14419296, /*Answer for n = 36 is*/ 22838014, /*Answer for n = 37 is*/ 35548790, /*Answer for n = 38 is*/ 56153296, /*Answer for n = 39 is*/ 87640646, /*Answer for n = 40 is*/ 138180196, /*Answer for n = 41 is*/ 216065986, /*Answer for n = 42 is*/ 340223834, /*Answer for n = 43 is*/ 532680994, /*Answer for n = 44 is*/ 838025410, /*Answer for n = 45 is*/ 1313251780, /*Answer for n = 46 is*/ }; Edited by author 31.12.2019 16:33 Thanks for the sequence! The problem is indeed solved with linear recurrence (your message from 2012). Although, it seems k=20 here, and one needs to run Gauss on 20x20 matrix. I got by solution by using Berlekamp—Massey though. I wonder, how could you guess there is a linear recurrence and that K is small enough to brute force the sequence in finite time (I assume that's how you got it). Edited by author 31.12.2019 18:41 | | Easy solution C++ | Znol | 1902. Neo-Venice | 31 Dec 2019 17:07 | 1 | #include <string> #include <iostream> #include <algorithm> #include <iomanip> #include <math.h> using namespace std; int main() { double n, t, s; cin >> n >> t >> s; double opposite[1000]; for (int i = 0; i < n; i++) { cin >> opposite[i]; if (opposite[i] >= s) { cout << fixed << setprecision(6) << ((opposite[i] + (s + t)) / 2) << endl; } else { cout << fixed << setprecision(6) << ((s + (opposite[i] + t)) / 2) << endl; } }
} | | Test 6 Access Violation | Znol | 1001. Reverse Root | 31 Dec 2019 14:43 | 1 | I think the promblem is in i-=2; This is to reduce i for ^Z symbol; idk how to fix this. #include <iostream> #include <algorithm> #include <iomanip> #include <math.h> using namespace std; int main() { double num[1000]; int i = 0; for (i; cin; i++) { cin >> num[i]; } for (i-=2; i >= 0; i--) {
cout << fixed << setprecision(4) << sqrt(num[i]) << endl; } } | | Minimum n for k=18 ? | Mickkie | 2049. Chemistry | 30 Dec 2019 20:46 | 2 | Does solution for (n,k) (19,18) exist? I only find the answer for (21,18). Do you guy have a better idea? 31 2 1 4 3 3 1 1 5 7 6 6 5 5 1 1 5 9 8 8 5 5 10 12 11 11 10 10 5 5 1 1 5 13 10 10 5 5 14 16 15 15 14 14 5 5 14 18 17 17 14 14 19 21 20 20 19 19 14 14 5 5 1 turns out n=19 you can reach state (10,9) and get to (1,18) this problem has the very beautiful soln. thanks to author. | | unable to understand first example. can anyone please kindly explain. | anupam ghosh | 1671. Anansi's Cobweb | 30 Dec 2019 17:16 | 1 | unable to understand first example. can anyone please kindly explain. | | So easy / phyton 3 solution | SMMaster | 1021. Sacrament of the Sum | 30 Dec 2019 14:32 | 1 | o = 0 k = int(input()) a = [0] * (65536*2) for i in range(k): a[int(input()) + 32768] = 1 h = int(input()) for i in range(h): if a[10000 - int(input()) + 32768] != 0: o += 1 if o >= 1: print('YES') else: print('NO') | | Test 8 python | bhn | 1196. History Exam | 30 Dec 2019 14:31 | 7 | time limit exceed on python3 there a code: a=[] for i in range(int(input())): a.append(input()) b=[] n=0 for j in range(int(input())): if input() in a: n+=1 print(n) please help me There is "Time limit exceeded" with binary search too. i think that on python i wil not can solve this import sys ll = set() for i in range(int(sys.stdin.readline())): ll.add(sys.stdin.readline()) n = 0 for j in range(int(sys.stdin.readline())): if sys.stdin.readline() in ll: n += 1 print(n) | | TLE #8: How can I make this Python code faster? | Neeraj Kumar | 1196. History Exam | 30 Dec 2019 14:30 | 2 | import sys p = input() p_list = [] for i in range(int(p)): x = input() p_list.append(x) s = input() s_list = [] for i in range(int(s)): x = input() s_list.append(x) count = 0 l = set(s_list).intersection(p_list) for i in l: count += s_list.count(i)
print (count) import sys ll = set() for i in range(int(sys.stdin.readline())): ll.add(sys.stdin.readline()) n = 0 for j in range(int(sys.stdin.readline())): if sys.stdin.readline() in ll: n += 1 print(n) | | So easy / phyton 3 solution | SMMaster | 1567. SMS-spam | 29 Dec 2019 17:53 | 1 | a = input() s = 0 ll = ['c','f','i','l','o','r','u','x','!'] hh = ['b','e','h','k','n','q','t','w','z',','] pp = ['a','d','g','j','m','p','s','v','y','.',' '] for i in range(len(a)): if a[i] in ll: s+=3 elif a[i] in hh: s+=2 elif a[i] in pp: s+=1 print(s) | | Hint. | some_programming_novice | 1059. Expression | 29 Dec 2019 07:19 | 1 | Hint. some_programming_novice 29 Dec 2019 07:19 | | Why Wrong Answer №6? | despair_101 | 1263. Elections | 28 Dec 2019 21:59 | 1 | using System; namespace Training { class Program { static void Main(string[] args) { string[] n = Console.ReadLine().Split(' '); int N = Convert.ToInt32(n[0]); int M = Convert.ToInt32(n[1]); double cnt = 1; int arr = 0; int[] ans = new int[M]; double[] vs = new double[N]; for (int i = 0; i < M; i++) ans[i] = Convert.ToInt32(Console.ReadLine()); Array.Sort(ans); Array.Resize(ref ans, ans.Length+1); Console.WriteLine(); for (int j = 0; j < M; j++) { if (ans[j] == ans[j + 1]) cnt++; else { double x = Math.Round(cnt / M * 100, 2); if ((int)x == x) Console.WriteLine(x + ".00%"); else Console.WriteLine(x + "%"); arr++; cnt = 1; } } if (arr < N) for (int j = 0; j < N - arr; j++) Console.WriteLine("0.00%"); } } } | | hint | Desserg | 1353. Milliard Vasya's Function | 27 Dec 2019 10:44 | 1 | hint Desserg 27 Dec 2019 10:44 Python 3 when counting by force I met TLE on the 45th test. I printed out all the values of the function and saw that it is mirrored after 40 values. f (40) = f (41) f (39) = f (42) ... f (2) = f (79) therefore, counting only to 40, I got Accepted | | I got WA on test 39 I need help | cjrsacred | 1519. Formula 1 | 27 Dec 2019 02:29 | 2 | #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const int maxn = 12; const int maxst = 50000 + 5; const int orz = 19260817; struct Hash { int cnt[orz]; ull val[orz]; int head[orz], nxt[orz], sz; void inline insert(ull u, int c) { int v = u % orz, i, lst = 0; for(i = head[v]; i; lst = i, i = nxt[i]) if(val[i] == u) break; if(i) cnt[i] = c; else { if(lst) nxt[lst] = ++sz; else head[v] = ++sz; val[sz] = u, cnt[sz] = c; } } int inline find(ull u) { int v = u % orz, i; for(i = head[v]; i; i = nxt[i]) if(val[i] == u) return cnt[i]; return 0; } } vti; ull itv[maxst]; int tot; int n, m; char board[maxn + 3][maxn + 3]; int ptn[maxst][maxn + 2]; int fi, fj; void inline getptn(int id) { ull st = itv[id]; int stk[maxn], cnt = 0; for(int i = 1; st; st >>= 2, ++i) { int p = st & 3; if(p == 1) stk[++cnt] = i; else if(p == 2) ptn[id][i] = stk[cnt], ptn[id][stk[cnt--]] = i; } } void dfs(ull st, int dep, int k) { if(dep > n + 1) { if(k) return; itv[++tot] = st; vti.insert(st, tot); return; } if(k > n + 1 - dep + 1) return; dfs(st, dep + 1, k); // # dfs(st | (1 << (2 * (dep - 1))), dep + 1, k + 1); // ( if(k) dfs(st | (2 << (2 * (dep - 1))), dep + 1, k - 1); // ) } void inline Init() { scanf("%d %d", &n, &m); for(int i = 1; i <= n; ++i) scanf("%s", board[i] + 1); for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) if(board[i][j] == '*') board[i][j] = 0; else board[i][j] = 1; dfs(0, 1, 0); for(int i = 1; i <= tot; ++i) getptn(i); // printf("tot = %d\n", tot); for(int i = n; i; --i) { for(int j = m; j; --j) { if(board[i][j]) { fi = i, fj = j; // printf("fi = %d, fj = %d\n", fi, fj); return; } } } } ll f[maxn + 2][maxn + 2][maxst]; ull inline fillas(ull S, int k, int c) { S &= ~(3 << (2 * (k - 1))); // set zero S |= c << (2 * (k - 1)); // set c return S; } void inline Solve() { f[0][m][vti.find(0)] = 1; for(int i = 0; i <= n; ++i) { for(int j = 1; j <= m; ++j) { for(int k = 1; k <= tot; ++k) { ull st = itv[k]; if(!f[i][j][k]) continue; // cut (=^o^=) // printf("f[%d][%d][%d] = %lld\n", i, j, k, f[i][j][k]); int tj = j + 1, ti = i; if(tj > m) tj = 1, ti = i + 1; // get target.
int left = (st >> (2 * (tj - 1))) & 3; // left plug int top = (st >> (2 * tj)) & 3; // top plug // printf("[%d, %d] -> [%d, %d] with left = %d, top = %d.\n", i, j, ti, tj, left, top);
if(!left && !top) { // no plug if(!board[ti][tj]) { // if cannot ull S = st; // do nothing if(tj == m) S = fillas(S, n + 1, 0), S <<= 2; f[ti][tj][vti.find(S)] += f[i][j][k]; } else if(board[ti + 1][tj] && board[ti][tj + 1]) { // can ? ull S = fillas(fillas(st, tj, 1), tj + 1, 2); // fill it if(tj == m) S = fillas(S, n + 1, 0), S <<= 2; f[ti][tj][vti.find(S)] += f[i][j][k]; } }
else if(left == 1 && top == 1) { // double left int pp = ptn[k][tj + 1]; // get partner ull S = fillas(fillas(fillas(st, tj, 0), tj + 1, 0), pp, 1); if(tj == m) S = fillas(S, n + 1, 0), S <<= 2; f[ti][tj][vti.find(S)] += f[i][j][k]; }
else if(left == 2 && top == 2) { // double right int pp = ptn[k][tj]; // get partner ull S = fillas(fillas(fillas(st, tj, 0), tj + 1, 0), pp, 2); if(tj == m) S = fillas(S, n + 1, 0), S <<= 2; f[ti][tj][vti.find(S)] += f[i][j][k]; }
else if(left == 2 && top == 1) { // right and left ull S = fillas(fillas(st, tj, 0), tj + 1, 0); // connect them directly if(tj == m) S = fillas(S, n + 1, 0), S <<= 2; f[ti][tj][vti.find(S)] += f[i][j][k]; }
else if(left == 1 && top == 2) { // left and right if(ti == fi && tj == fj) { // end block only ull S = fillas(fillas(st, tj, 0), tj + 1, 0); // connect them directly if(tj == m) S = fillas(S, n + 1, 0), S <<= 2; f[ti][tj][vti.find(S)] += f[i][j][k]; } }
else { // one have plug but another no // printf("ah?\n"); if(board[ti + 1][tj]) { // if down can to ull S = fillas(fillas(st, tj, left + top), tj + 1, 0); // set if(tj == m) S = fillas(S, n + 1, 0), S <<= 2; // printf("%d %llu\n", vti.find(S), S); f[ti][tj][vti.find(S)] += f[i][j][k]; } if(board[ti][tj + 1]) { // if right canto ull S = fillas(fillas(st, tj, 0), tj + 1, left + top); // set if(tj == m) S = fillas(S, n + 1, 0), S <<= 2; f[ti][tj][vti.find(S)] += f[i][j][k]; } } } } } } int main() { Init(); /* for(int i = 1; i <= tot; ++i) { printf("id: %d, st: %llu\n", i, itv[i]); }*/ Solve(); printf("%lld\n", f[n][m][1]); return 0; } Don't want to read the code, but 39 test apparently is something like less than 12 rows with 12 columns and all empty. I had bug in this one: 2 12 ............ ............ Result should be obviously 1. | | WA34 on Python 3 | Moshkov Danil | 2148. Insane Shot | 24 Dec 2019 18:39 | 2 | Somebody had this test case? Try this tests: 0 0 5 -5 100 -5 -100 ans: No way 0 0 5 5 100 5 -100 ans: No way 0 0 100 5 100 -5 100 ans: No way 0 0 100 5 -100 -5 -100 ans: No way | | getting TLE at test 55 | anupam ghosh | 2111. Plato | 24 Dec 2019 06:11 | 1 | Is there any algorithm to be applied except sorting? | | WA 27 : some test cases please | anupam ghosh | 2111. Plato | 24 Dec 2019 06:10 | 2 | | | wrong in test case 4 why? | asdfg | 1068. Sum | 23 Dec 2019 12:16 | 1 | #include <iostream> using namespace std; int main() { int n,sum=0; cin>>n; if(n==0 || n==1) { cout<<1<<endl; }
if(n>1) { for(int i=2;i<=n;i++) {
sum=sum+i; } cout<<sum<<endl; } if(n<0) { n=n*-1; for(int i=2;i<=n;i++) {
sum=sum+i; } cout<<"-"<<sum<<endl; }
return 0; } | | If you wa on test 5 | binario | 1752. Tree 2 | 21 Dec 2019 11:31 | 1 | try this test: 21 1 1 2 2 3 3 4 4 5 4 6 6 7 7 8 5 9 9 10 10 11 11 12 1 13 12 14 14 15 15 16 13 17 16 18 18 19 19 20 20 21 8 15 answer: 21 | | For whom, who got wa4,5,6 | Gleb_Kazantaev(NNSTU) | 1123. Salary | 21 Dec 2019 11:21 | 2 | Try this tets: 1999992 2000002 1009002 1010101 |
|
|