Общий форумWhy first test isn't like in sample? I checked there are only 1 test, and it is "18". Where another 17 tests have gone? N=input() ans=2 print ans for i in range(0,N): ans=(ans-1)*ans+1 print ans It returns correct answer on my PC,but gets WA when submitted. Well, there is only one test in check system. And it is: 18 I don't know why first test isn't "2". # include <iostream> # include <fstream> # include <cmath> # include <vector> # include <algorithm> # include <math.h> # include <time.h> # include <string> # include <string.h> # include <map> # include <queue> # include <stack> using namespace std; const int MAXN = 1000000007;//, Maxn = 1000000009; long long n, a, san, num, dereje = 1, x; bool zero, one; string s, h; int main() { cin >> n >> s >> h;
a = n-1;
for (int i=0; i<n; i++) { san = (san + (dereje * (s[i]-'a'+1))) % MAXN; num = (num + (dereje * (h[i]-'a'+1))) % MAXN; dereje = (dereje * 27) % MAXN; }
if (san == num) {cout << 0 << '\n'; return 0;}
for (int i=0; i<n; i++) { san = (san * 27) % MAXN, san = (san - (((s[a]-'a'+1) * dereje) % MAXN)), san = (san + MAXN) % MAXN, san = (san + (s[a]-'a'+1)) % MAXN;
if (san == num) {cout << i+1 << '\n'; return 0;} a--; }
cout << -1 << '\n';
return 0; } WA 8.why? i used HASH! plz help me! #include <iostream> using namespace std; int main() { int aNumber, bNumber; cin>>aNumber; cin>>bNumber; if(bNumber > aNumber) { cout<< ((bNumber-(aNumber + (aNumber%2? 0:1) ))/2) + 1; } else if(bNumber == aNumber) { cout<<"1"; } } what might be test case #4 ? Try this: 4 4 The answer should be 0. Edited by author 02.04.2015 00:59 tell me how to use the compiler, if changed (macbook)OSX. Can I xCode? What is "Idleness limit exceeded"? What is in test #7 ?? Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; var n = int.Parse(Console.ReadLine().Trim()); int a = 0; var p = (int)Math.Truncate(Math.Sqrt(n + n)); while (p > 1) { var s = n - p * (p + 1) / 2; if (s >= 0) { int rem; a = Math.DivRem(s, p, out rem); if (rem == 0) break; } p--; } a++; Console.WriteLine("{0} {1}", a, p); I got it! [code deleted] Edited by moderator 21.10.2019 23:03 What's test 9. I've got WA too. Try these tests: 3 3 2 ABC AB BC the answer is 16. 2 6 1 AB ABAB the answer is 53. I had WA#9 as well. My DFA was too primitive. Think about cases, when some word's prefix is contained in other word. For example, "dabc" and "abd" -- "ab" is prefix of "abd" and is contained in "dabc". It would be nice, if automaton can recognize words like "dabd". Regards, Denis Firsov tests: 2 4 3 ab abab abb baa answ:7 6 6 2 abcdef dabcab abdef answ:46643 Edited by author 30.03.2015 09:25 Edited by author 31.03.2015 06:18 what's the differance between sort and stable_sort in C++? Edited by author 21.07.2013 20:38 Edited by author 21.07.2013 20:39 sort() is a realization of Quick Sort, stable_sort() is Merge Sort. Не знаю английского, извините админы :( Помогите пожалуйста, всё время выскакивает эта ошибка на 8 или на 9 тесте. Пишу на C# помогите оптимизировать код. using System; namespace EkzamenIstorii { class Program { static void Main() { Work work = new Work(); work.Start(); } } class Work { int[][] TichersDate; int[] UchenikDate; int Sovpadenia, buf=0; public void Start() { Input(); Algoritm(); Output(); } void Input() {
int CountTichersDates = int.Parse(Console.ReadLine()); buf = CountTichersDates / 1000; buf += 1; TichersDate = new int[buf][]; for (int i = 0; i < buf; i++) { TichersDate[i] = new int[1]; for (int j = 0; j < CountTichersDates; j++) { TichersDate[i][j] = int.Parse(Console.ReadLine()); Array.Resize(ref TichersDate[i], TichersDate[i].Length + 1); if (i == 999) { CountTichersDates -= 1000; break; } } Array.Resize(ref TichersDate[i], TichersDate[i].Length-1); }
int CountUchenikDate = int.Parse(Console.ReadLine()); UchenikDate = new int[CountUchenikDate]; for (int i = 0, j=0; i < UchenikDate.Length; i++) UchenikDate[i] = int.Parse(Console.ReadLine()); } void Algoritm() { for (int k = 0; k < UchenikDate.Length; k++) { bool flag = false; for (int i = 0; i < buf; i++) { if (UchenikDate[k] >= TichersDate[i][0] && UchenikDate[k] <= TichersDate[i][TichersDate[i].Length-1]) for (int j = 0; j < TichersDate[i].Length; j++) if (UchenikDate[k] == TichersDate[i][j]) { Sovpadenia++; flag = true; break; } if (flag) break; } } } void Output() { Console.WriteLine(Sovpadenia); } } } Я не знаю СИ шарп, но могу подсказать алгоритм. Я делал так: Записываем в массив 1 список преподавателя Удаляем дубликаты Начинаем считывать элементы студента по одному(никуда их не записываем), когда считываешь сразу проверяешь есть ли такой в списке преподавателя, если есть то счетчик+1. Потом просто вывести показания счетчика. Не знаю как на Си шарп, на С++ пользовался STL получилось за 0.4s и 800kb памяти. Удачи! Куда там! Я на Паскале сразу формировала при вводе массив неповторяющихся дат преподавателя, потом так же считывала и сразу искала совпадения студента по преподу и вылетала из цикла поиска. Но!!! 8 тест - тайм лимитед. Может, Паскаль виноват? Потому что на всех моих тестах идет все четко. var a:array[1..15000] of longint; i,n,j,k,flag,b,m:longint; k1 :longint; begin k:=0; read(n); read(a[1]);k:=1; if n>1 then begin for i:=2 to n do begin read(b); flag:=0; j:=1; repeat if a[j]=b then begin flag:=1; end; j:=j+1; until (flag=1) or (j>k); if flag=0 then begin k:=k+1; a[k]:=b;end; end; end; read(m); for i:=1 to m do begin read(b); j:=1; flag:=0; repeat if a[j]=b then begin flag:=1; k1:=k1+1;end; j:=j+1; until (flag=1) or (j>n); end; writeln(k1); end. НО!!! на 8 тесте тайм лимитед. ну, что еще надо??? прохелпите!!! плиз Thanks Valdemar. This word helped me a lot "Удаляем дубликаты". __author__ = 'abdujabbor' import sys numbers = { 0: {'o', 'q', 'z'}, 1: {'i', 'j'}, 2: {'a', 'b', 'c'}, 3: {'d', 'e', 'f'}, 4: {'g', 'h'}, 5: {'k', 'l'}, 6: {'m', 'n'}, 7: {'p', 'r', 's'}, 8: {'t', 'u', 'v'}, 9: {'w', 'x', 'y'}} while True: number = input() if(number == '-1'): sys.exit(0) words_counter = int(input()) words_list = [] result = [] for x in range(0, words_counter): word = input() words_list.append(word) i = 0 t = 0 for word in words_list: found = False finded_word = '' current_position = i for item, c in enumerate(word): if c in numbers[int(number[i])]: i += 1 finded_word += c else: break if finded_word == word: result.append(finded_word) else: i = current_position t += 1 result_words = ' ' if len(result) > 0: print(result_words.join(str(item) for item in result)) else: print('No solution.') I know AC solution that answers 0 to the following test: 1 29999 30000 New tests were added. Read Site news. thank you . you inspired me! Pls tell me what does author of this problem mean.. If all delegates are in different rooms then we can't use less than 4 connections to achieve the goal in sample input. What 3 connections can we use to do it? Do we need all M pairs to be in answer? I still can't solve it because statement is too loose for me. The line "every connection is made between people that can negotiate" actually means "a connection can only be made between two people that can negotiate". Please give me tests. Always WA #3. I'm writing in Go and using float64 for the numbers. maybe use long long,then you will get it. O(sqrt(2 * N)) I have: A = (2 * N - P * P + P ) / ( 2 * P ) and P = [1, 2, 3, ..., sqrt(2 * N) + 3] :D I got AC ... Got WA2. please respond. Cleared the fault. But now WA 16. Cleared the fault. But now WA 16. Using C++. Is it a problem due to using long double? See this test: 6 2 2 2 3 3 3 Bad answer: 5 Good answer: 3 Maybe new problem with increase S,K) 5 500 250 250 250 250 250 ------------------- 22288580 I'm curious how do you solve this problem so fast, could you give me some hint?? or send you code to my email:qizichao@gmail.com THX I managed to reach the same time, but only once :) |
|