Общий форумWhat's the meaning of "Land fragments that are adjacent to the map's border are not considered as islands." ??? I can hardly understand it ! in the Example input, There is two island adjacent to the map's border(the north-east corner and the south-west corner) . but the answer is 3 !!! can anyone help me ? In the first sample I checked the sacred islands' territory as '*': ........# .*******. .*.....*. .*.*.*.*. .*.....*. .*******. #........ So, there are 3 sacred islands. The land fragments in the corners of the map are not the islands, because they are adjacent to the map's border. but those islands are not in the same sea /\/\/ \/\/\ /\*\/ \/\/\ /\/\/ ans: FAIL \/\/\ \/\/* //\// \\\// \/\\/ ans: U2 /\/// \/\\/ /\\*\ \/\// /\/\\ ans: WIN \\/// //\// *\\\\ \\\/\ //\// ans: U1 \/\// \/\\\ ///// *\\\\ \//\/ ans: WIN so this is a NP complete problem ,how can it be solved with 1000 range.. I don't know Can anybody tell me test 5,i am getting WA.I have tried my code on many random cases and it works fine. Code:- #include<bits/stdc++.h> #define PB push_back #define MP make_pair #define F first #define S second #define SZ(a) (int)(a.size()) #define SET(a,b) memset(a,b,sizeof(a)) #define LET(x,a) __typeof(a) x(a) #define TR(v,it) for( LET(it,v.begin()) ; it != v.end() ; it++) #define loop(i,a,b) for(int i=a;i<b;i++) #define si(n) scanf("%d",&n) #define sll(n) scanf("%lld",&n) #define sortv(a) sort(a.begin(),a.end()) #define all(a) a.begin(),a.end() #define bitcount(n) __builtin_popcount(n) #define DRT() int t; cin>>t; while(t--) #define TRACE #ifdef TRACE #define trace1(x) cerr << #x << ": " << x << endl; #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl; #define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl; #define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl; #define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl; #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl; #else #define trace1(x) #define trace2(x, y) #define trace3(x, y, z) #define trace4(a, b, c, d) #define trace5(a, b, c, d, e) #define trace6(a, b, c, d, e, f) #endif using namespace std; typedef long long int lli; typedef pair<int,int> ii; typedef vector<int> vi; typedef vector< vi > vvi; typedef vector< ii > vii; lli modpow(lli a,lli n,lli temp){lli res=1,y=a;while(n>0){if(n&1)res=(res*y)%temp;y=(y*y)%temp;n/=2;}return res%temp;} //***********************************END OF TEMPLATE********************************************************************* const int MAX = 50005,MAX2=log2(MAX); int d[MAX],h[MAX],P[MAX][MAX2],n; vector<vii> graph(MAX); void dfs(int u,int p){ P[u][0]=p; h[u]=h[p]+1; for(auto k:graph[u]){ if(k.F==p)d[u]=d[p]+k.S; else dfs(k.F,u); } } void init(){ for(int i=0;i<n;++i){ for(int j=0;(1<<j)<n;++j)P[i][j]=-1; } d[0]=0; h[0]=-1; dfs(0,0); for(int j=1;(1<<j)<n;++j){ for(int i=0;i<n;++i){ if(P[i][j-1]!=-1)P[i][j]=P[P[i][j-1]][j-1]; } } } int lca(int u,int v){ if(h[u]>h[v])swap(u,v); int l=log2(h[v]); for(int i=l;i>=0;--i){ if(h[v]-(1<<i)>=h[u]&&P[v][i]!=-1)v=P[v][i]; } //u and v at same level if(u==v)return u; for(int i=l;i>=0;--i){ if(P[u][i]!=P[v][i]&&P[u][i]!=-1){ u=P[u][i]; v=P[v][i]; } } return P[u][0]; } int query(int u,int v){ int lc = lca(u,v); return d[u]+d[v]-2*d[lc]; } int main(){ int u,v,w,q; si(n); loop(i,1,n){ si(u);si(v);si(w); graph[u].PB(MP(v,w)); graph[v].PB(MP(u,w)); } init(); si(q); while(q--){ si(u);si(v); printf("%d\n",query(u,v)); } return 0; } Edited by author 17.01.2016 01:13 wa#4 for countless times, seek for kind help! thanks var a,b,c,i,k:real; begin read(a,b,c); while a>b do begin a:=a-(a*c/100); I:=i+1; end; write(i); end. variable i should be integer ! Here is the code (python 3.6). Can anyone explain, why it fails on test 9? import math string = input().split() start = int(string[0]) end = int(string[1]) commission = int(string[2]) if start <= end: n = 0 else: q = 1 - commission / 100 n = math.log((end / start), q) n = round(n) print(n) Use float / double instead of int ! 1) Find the prime numbers up to 10,000,100 (Sieve of Eratosthenes) 2) if the sum is equal to 19 degrees, then the residue is prime to check What can you advise? 1) Up to 10M? 2M is enough. sqrt( 10^18 / 2^18) ~= 1.5M 2) "Yes" precondition: N > 1 "Yes" condition: sum is 20 and residue is 1 "Yes" condition: sum is 19 and residue>1 and residue is prime Could you show please code? AC Edited by author 09.03.2017 18:16 > if (kol == 20){ It's suspicious a bit. Please try test (2^20)*3, expected answer is No 3145728 No 20^20 * 3^1 sum 21 if I understand condition of the problem: 3^1*5^1*7^2*11^1*17^12*23^3 answer is "Yes" ? Edited by author 01.03.2017 13:26 In Idea my code works, but here is a runtime error: import java.util.Scanner; public class MathematiciansAndBerries { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); byte a1 = scanner.nextByte(); byte b1 = scanner.nextByte(); byte a2 = scanner.nextByte(); byte b2 = scanner.nextByte(); byte a3 = scanner.nextByte(); byte b3 = scanner.nextByte(); System.out.println((a1 - a3) + " " + (b1 - b2)); } } Help pls, why runtime error occurs? Edited by author 06.12.2018 21:47 Changed byte to int and now it works ok here. Idiotic. I don't think a mathematician can bring more than 127 kg)) "0 <= ai, bi <= 10,000" Sure, do not read condition is idiotic. I think I can not get AC because of "Enter" key on Windows is "\r\n" and C++ scanf() reads it as "\n" and printf() writes "\n" as "\r\n". So, if in input is some "\n", then I would read it as "\n" and then print it as "\r\n"!!! I don't know how to fix that. Also there were problems with EOF-character. Yeah, I have the same problem! My ass is burning after solving this problem The test is empty. There is nothing there. I really don't understand why my solution is wrong but here it is: letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" start = 0 s = input() for i in range(0, len(s)): if not(s[i] in letters): word = s[start:i] other = s[i:i+1] if (word != ""): print(word[::-1], end="")
print(other, end="") start = i+1 if (start != len(s)): print(s[start:len(s)][::-1], end="") What's wrong with this solution? WA (Test 2) Edited by author 30.03.2013 23:10 I think that the input can be more than one line. верно ли,что при n=48,ответ 793566522023068987143383410279408208612410000 а при n=100 3834688188199309756675466732967588185862422492337212276545580039517258085033387305291001857619600 Hello. I have received strange 'Compilation Error' verdict for my solution on the 1314 task under Microsoft Visual C++ 2017 compiler. Compilation log is as follows: ///////////////////////////////////////// lg1vr1-w2nnli(24): error C2062: type 'float' unexpected lg1vr1-w2nnli(84): warning C4244: 'argument': conversion from 'float' to 'const int', possible loss of data lg1vr1-w2nnli(94): warning C4018: '<': signed/unsigned mismatch ///////////////////////////////////////// Lines 23 and 24 of my code are: ///////////////////////////////////////// const int MAX_STATION_ID = 32767L; const int INFINITY = 10L * MAX_STATION_ID; ///////////////////////////////////////// Commits with CE are 8162255, 8162250, 8162248. But there is successful (Accepted) commit 8162257 (the same code as 8162255) under G++7.1 commit. Could you check if the CE message was correct or not? Best regards. Edited by author 04.12.2018 02:01 Please give me test 12. try ()() thank you very much. It's just like the test of the compiler. try ()() if you have TLE #20. Use BufferedReader and Printwriter in Java. Good luck... Thanks a lot! I don't really understand why PrintWriter works faster than System.out... Hints for Java'ers who also hates problems like this and doesn't want to write automation-based solution. new BigDecimal(line1) - it's almost cool, but you need some fixes before use constructor 1. Check for empty fraction case, e.g. "1.", "1.e2", "1.E2" - these are NANs according P1074 grammar, but OK according BigDecimal grammar (this is the only difference in grammars). 2. Fix big exponent to something smaller, for BigDecimal to be able to parse it e.g. e1000000000000 => e1000 e-1000000000000 => e-1000 Edited by author 09.02.2013 06:24 can you show your answer? <input (replace 'S' with spaces!):> S 1 34 10 - 1 -. 1 -.e0 1 -.1e 1 #123 1 --123 1 -1.e6 1 S4 4 12345678e-100000000000000000000000000000 10 0.0e10000000000000000000000 1 # <output:> Not a floating point number 34.0000000000 Not a floating point number Not a floating point number Not a floating point number Not a floating point number Not a floating point number Not a floating point number Not a floating point number Not a floating point number 0.0000000000 0.0 <input> #S 1 S# 1 # <output> Not a floating point number Not a floating point number Thank you so much! very helpful I use segment tree to solve this problems(O(n^2logn)). And I have checked my program with an solution(already accepted) for many times. All my answer is correct. But still wa#2. Sorry for my poor English. Please help me,Thank you. After I have correct my code. I got wa#85 now!!! faint! Who can help me? For WA #2 one should make sure that the Segment Tree is initialized to -INF. |
|