|
|
Общий форум1. This problem can be reduced to the following: Given X, find two vertices such that path weight is equal to X. 2. It probably cannot be solved with naiive DP. Use centroid decomposition. 3. std::unordered_map gets TL while std::map gets AC. i have some problems with (), please give answers for some other cases 1 Edited by author 06.11.2015 00:47 Input: 4 Output: (((sin(1)+4)sin(1-sin(2))+3)sin(1-sin(2+sin(3)))+2)sin(1-sin(2+sin(3-sin(4))))+1 What it is it? My program overcome all my tests,but system(TIMUS) written me about WA#9! WHY? me too! any ideas, please send to: williamm2006@126.com thanks! program p1406; var a:array[1..2000]of longint; ch:char; i,j,k,n,m:longint; begin while not eof(input) do begin read(ch); if ch in['0'..'9'] then begin inc(n); a[n]:=ord(ch)-48; end; end; for i:=n downto 1 do if a[i]>0 then break; if((i=1)and(a[i]=0))or(n=1) then begin writeln(-1); halt; end; j:=i-1;m:=a[i]-1;a[i]:=0; for j:=i-1 downto 1 do if a[j]<>9 then break; if(j=1)and(a[j]=9) then begin writeln(-1); halt; end; inc(a[j]); for i:=j+1 to n do begin inc(m,a[i]); a[i]:=0; end; i:=n; while m>0 do begin if m>=9 then a[i]:=9 else a[i]:=m; dec(i); dec(m,9); end; for i:=1 to n do write(a[i]); writeln; end. Don't be afraid of geometry, this problem is really easy Please, fix English in the statement: is maked -> is made You standing -> You're standing you have made -> you made Thank you! Is it supposed to be solved without floating-point numbers at all? This problem is definitely can be solved using integers only Don't be afraid of geometry, this problem is really easy I confirm :) #include<iostream> using namespace std; int sum(int temp); int main(){ int a[6]; scanf("%1d%1d%1d%1d%1d%1d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]); int first=a[0]*100+a[1]*10+a[2]; int second=a[3]*100+a[4]*10+a[5]; if(a[3]==9&&a[4]==9&&a[5]==9){ cout<<"No"; return 0; } int pre=second-1; int next=second+1; if((sum(pre)==(a[0]+a[1]+a[2]))||(sum(next)==(a[0]+a[1]+a[2]))){ cout<<"Yes"; }else{ cout<<"No"; }
return 0; } int sum(int temp){ int count=0; do{ count+=(temp%10); temp/=10; }while(temp/10!=0); count+=temp; return count; } #include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; class team{ public: string id; int n; }; bool comp(const team &t1,const team &t2); int main(){ int k; cin>>k; vector<team> T; while(k--){ string temp; int num; cin>>temp>>num; team t; t.id=temp; t.n=num; T.push_back(t); } stable_sort(T.begin(),T.end(),comp); for(int i=0;i<T.size();++i){ cout<<T[i].id<<" "<<T[i].n<<endl; }
return 0; } bool comp(const team &t1,const team &t2){ return t1.n>t2.n; } Why Wring answer? import java.util.Scanner; public class T1654 { public static char[] arr; public static String out = ""; public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); String inp = sc.next(); sc.close(); arr = new char[inp.length()]; arr = inp.toCharArray(); format(); if(out != "") { System.out.println(out); } else { System.out.println(""); }
}
public static void format() { boolean isFormat = false; int l = arr.length; for(int i = 0; i< l-1; i++) { if(arr[i] == arr[i+1]) { arr[i] = 0; arr[i+1] = 0; isFormat = true; } else if(arr[i] != arr[i+1] & arr[i] != 0){ out += arr[i]; } } out+= arr[arr.length-1]; if(isFormat == true) { arr = new char[out.length()]; arr = out.toCharArray(); out = ""; format(); } } } получил АС, долго искал где долбанный баг, т.к. ТЕСТ 22 выдавал ошибку по времени, если у вас такая же проблема и вы используете преобразование double в int то в 22 тесте точность P и Q 3 знака, поэтому ТЛ и выдает, вероятно на вход подаются какие нибудь числа 22.333 и 22.334 удачи You are wrong! P and Q are given with up to 2 digits after decimal point in all tests. похожая фигня, точности 2 знаков после запятой не хватало, впилил третий знак, всё заработало code like: size_t out = 0; printf ("%zu\n", out); result - > wa#1 ((( if i use printf ("%d\n", out); all test accepted (( Why? https://wandbox.org/ & gcc 7.1 - The first version works correctly ((( i have ac in 0.187 s, but on this test my program runs at least 0.9: 35 123 2 3 4 5 6 0 8 9 10 11 0 13 14 15 0 17 18 0 20 21 0 23 0 25 0 27 0 0 0 0 0 0 0 0 0 I've got accepted after adding the condition of end of file in creating new line. May be, it will be useful. Edited by author 31.01.2016 15:50 Edited by author 31.01.2016 15:50 2 5 11 as fg asdf asdfr a qwer as s s qwer e Correct answer is 5 #include<iostream> #include<vector> #include<algorithm> using namespace std; int main(){ int k; cin>>k; vector<int> line1; vector<int> line2; vector<int> sum; while(k--){ int m,n; cin>>m>>n; line1.push_back(m); line2.push_back(n); } bool plus_1=false; for(int i=line1.size()-1;i>=0;i--){ int temp=line1[i]+line2[i]; if(plus_1){ temp++; } if(temp>=10){ plus_1=true; temp-=10; }else{ plus_1=false; } sum.push_back(temp);
} for(vector<int>::reverse_iterator iter=sum.rbegin();iter!=sum.rend();++iter){ cout<<*iter; } return 0; } I've been wa on this case for a long time: abaabaaba The right answer is abaabaabaaba Can anyone please suggest the test case which might give me WA35... I have used string , also tried with character array... and KMP algorithm ..... please do reply Edited by author 27.08.2018 13:31 Aren't 'abaabaaba' a palindrome? Can anybody please give me cases for Test2 ? If you only go through the matrix and saved the minimum value, it is not the solution for that problem. Really fast. for (int k = 0; k < n; ++k) { for (int i = graph[k]._Find_first(); i < n; i = graph[k]._Find_next(i)) { graph[k] |= graph[i]; } } I created array p[1..10000000] of boolean; p[i]=true when exist i in input. But i can t prove that if length of input <=100000 then absent numb <=10000000 because if you will write all numbers from 1 to 10000000. string length will be more than 10^5 Edited by author 11.02.2019 20:58 |
|
|