Common BoardNo clue as to what's wrong. Can anyone please give me a hint or what's the case? you can show your code , i can help you n = 228 -> ans = 2509198527 n = 121 -> ans = 2368799 n = 10 -> ans = 9 n = 150 -> ans = 19406015 n = 201 -> ans = 517361669 n = 300 -> ans = 114872472063 n = 500 -> ans = 732986521245023 I have WA8. Who can help with test? 6 ABAAAA AAAAAA -- Alice wins Edited by author 02.08.2021 17:16 #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> using namespace std; typedef long long ll; struct dw { ll a,f,s; }A[1600]; bool cmp(dw n1,dw n2) { if(n1.a==n2.a) { if(n1.f==n2.f)return n1.s<n2.s; else return n1.f<n2.f; } else return n1.a<n2.a; } ll ys1[1600],ys2[1600]; ll ans,ad,au,al,ar; struct node { ll l,r,lc,rc,lmax,ln,rmax,rn,mmax,sum,nn; ll L,R,lR,rL; bool have; }tr[3100];ll trlen=0; ll da=1501; void update(ll now) { ll lc=tr[now].lc,rc=tr[now].rc; tr[now].sum=tr[lc].sum+tr[rc].sum; tr[now].nn=tr[lc].nn+tr[rc].nn; ll qwq=-da,ql,qr; if(tr[lc].have){if(tr[lc].mmax>qwq){qwq=tr[lc].mmax;ql=tr[lc].L,qr=tr[lc].R;}} if(tr[rc].have){if(tr[rc].mmax>qwq){qwq=tr[rc].mmax;ql=tr[rc].L,qr=tr[rc].R;}} if(tr[lc].rn+tr[rc].ln>=2){if(tr[lc].rmax+tr[rc].lmax>qwq){qwq=tr[lc].rmax+tr[rc].lmax;ql=tr[lc].rL;qr=tr[rc].lR;}} if(qwq==-da)tr[now].have=false,tr[now].mmax=tr[now].L=tr[now].R=0; else tr[now].have=true,tr[now].mmax=qwq,tr[now].L=ql,tr[now].R=qr; tr[now].lmax=tr[lc].lmax,tr[now].ln=tr[lc].ln,tr[now].lR=tr[lc].lR; if(tr[lc].sum+tr[rc].lmax>=tr[now].lmax)tr[now].lmax=tr[lc].sum+tr[rc].lmax,tr[now].ln=tr[lc].nn+tr[rc].ln,tr[now].lR=tr[rc].lR; tr[now].rmax=tr[rc].rmax,tr[now].rn=tr[rc].rn,tr[now].rL=tr[rc].rL; if(tr[rc].sum+tr[lc].rmax>=tr[now].rmax)tr[now].rmax=tr[rc].sum+tr[lc].rmax,tr[now].rn=tr[rc].nn+tr[lc].rn,tr[now].rL=tr[lc].rL; } void bt(ll l,ll r) { ll now=++trlen;tr[now].l=l;tr[now].r=r;tr[now].lc=tr[now].rc=-1; tr[now].mmax=0;tr[now].have=0;tr[now].lmax=tr[now].rmax=0;tr[now].ln=tr[now].rn=0;tr[now].sum=tr[now].nn=0; tr[now].L=tr[now].R=tr[now].lR=tr[now].rL=0; if(l<r) { ll mid=(l+r)/2; tr[now].lc=trlen+1;bt(l,mid); tr[now].rc=trlen+1;bt(mid+1,r); update(now); } else tr[now].lR=tr[now].rL=l; } void change(ll now,ll x,ll k) { if(tr[now].l==tr[now].r) { tr[now].sum+=k;tr[now].nn++; tr[now].lmax=tr[now].rmax=tr[now].sum; tr[now].ln=tr[now].rn=tr[now].nn; if(tr[now].nn>=2)tr[now].mmax=tr[now].sum,tr[now].L=tr[now].R=x,tr[now].have=true; } else { ll lc=tr[now].lc,rc=tr[now].rc,mid=(tr[now].l+tr[now].r)/2; if(x<=mid)change(lc,x,k); else change(rc,x,k); update(now); } } ll n,z1,z2; void solve() { for(ll i=1;i<=n;i++) { trlen=0;bt(1,z2); ll st1=A[i].a,st=i; for(ll j=st1;j<=z1;j++) { bool bk=false; while(st<=n&&A[st].a==j){change(1,A[st].f,A[st].s);st++;bk=1;} if(bk) { if(tr[1].have) { if(ans<tr[1].mmax) { ans=tr[1].mmax; au=st1;ad=j; al=tr[1].L,ar=tr[1].R; } } } } while(i<n&&A[i+1].a==st1)i++; } } struct ls { ll x,id; }AA[1600]; bool cmp1(ls n1,ls n2){return n1.x<n2.x;} int main() { da*=1000000000; scanf("%lld",&n);ll z; for(ll i=1;i<=n;i++)scanf("%lld%lld%lld",&A[i].a,&A[i].f,&A[i].s); for(ll i=1;i<=n;i++)AA[i].x=A[i].a,AA[i].id=i; sort(AA+1,AA+n+1,cmp1);z=0; for(ll i=1;i<=n;i++) { if(i==1||AA[i].x!=AA[i-1].x){z++;ys1[z]=AA[i].x;} A[AA[i].id].a=z; }z1=z; for(ll i=1;i<=n;i++)AA[i].x=A[i].f,AA[i].id=i; sort(AA+1,AA+n+1,cmp1);z=0; for(ll i=1;i<=n;i++) { if(i==1||AA[i].x!=AA[i-1].x){z++;ys2[z]=AA[i].x;} A[AA[i].id].f=z; }z2=z; sort(A+1,A+n+1,cmp); ans=-da;solve(); printf("%lld %lld\n%lld %lld\n",ys1[au],ys1[ad],ys2[al],ys2[ar]); return 0; } ? 1 4 3 the answer is 3, not -1 #include <iostream> #include <string> int main() { int n, gCount = 2; std::cin >> n; std::string guest; while (n--) { std::cin >> guest; gCount++; if (guest.find("+one", 0) != std::string::npos) gCount++; } if (gCount == 13) gCount++; std::cout << gCount * 100 << std::endl;
return 0; } #include <iostream> #include <vector> #include <iterator> int main() { int N; std::cin >> N; char v; int h, c = 0; std::vector<int> result; while (N--) { std::cin >> v >> h; v = v - 'a' + 1; if (h > 1 && v > 2) c += 1; if (h > 1 && v < 7) c += 1; if (h > 2 && v > 1) c += 1; if (h > 2 && v < 8) c += 1; if (h < 8 && v > 2) c += 1; if (h < 8 && v < 7) c += 1; if (h < 7 && v > 1) c += 1; if (h < 7 && v < 8) c += 1; result.push_back(c); c = 0; } std::copy(result.begin(), result.end(), std::ostream_iterator<int>(std::cout, "\n")); return 0; } I get AC with using algorithm with O(n) complexity - just use sliding window Edited by author 28.07.2021 23:07 help me sol this problem my email : npsdn1906@gmail.com 1) Try writing an algorithm for finding the minimum difference in a list first (list.sort() method may come in handy) 2) Think of how the usage of sets and lists may assist you in determining whether we have doublets in your list 3) Use counters for finding the number of iterations in your cycle Enjoy :) Edited by author 25.07.2021 21:52 Edited by author 25.07.2021 21:52 I think it's easy problem and must be rated 30 check your last string after FOR. I missed this but now Accepted. You can use pbds_tree to solve this problem. PBDS Tree function named "order_by_key" will solve the problem like: find number of elements, which lower than x #include<iostream> #include<iomanip> #include<math.h> using namespace std; double a[10001]; int main() { int l=0,i,n,k; double x,m; cin>>n>>m; for(i=0;i<m;i++) { cin>>k; a[k]++; } for(i=1;i<=n;i++) { x=a[i]/m; x*=100; if(ceil(x)==floor(x))cout<<x<<".00%"<<endl; else cout<<setprecision(4)<<x<<'%'<<endl; } return 0; } Edited by author 09.04.2008 22:50 I have this Problem too. plz help, my program is been written in JAVA. Edited by author 13.10.2011 16:36 So, I have this problem too. What is the rigth solution? --- I found the answer, use Console.WriteLine("{0:f2}%", t); Edited by author 25.10.2012 19:37 Edited by author 25.10.2012 19:37 Try these inputs: 2 11 1 2 2 2 2 2 2 2 2 2 2 I change this >> first multiply 100 and then divide m . and it works. Check if the order RTLB is respected and pay attention to the fact that the matrix in the problem is inversed in comparison to the one that you build i.e. the bottom is curr_row - 1 and top is curr_row + 1. whats problem on test 3?? что за проблема на 3 тесте?? Yep Why my code get WA3? #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <cstring> #include <set> #include <map> #include <cmath> #include <algorithm> using namespace std; #define ll long long const ll nmax = 100005; const ll inf = 1234567890123; ll A, B, C; ll X, Y, Z; int main() { cin>>A>>B>>C; cin>>X>>Y>>Z;
if(Z > C) cout<<"There are no miracles in life"; else { ll ess = (ll)0; if(X > A) ess += X - A; if(Y > B) ess += Y - B; if(C - Z >= ess) cout<<"It is a kind of magic"; else cout<<"There are no miracles in life"; }
return 0; } or more simple #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <cstring> #include <set> #include <map> #include <cmath> #include <algorithm> using namespace std; #define ll long long const ll nmax = 100005; const ll inf = 1234567890123; ll A, B, C; ll X, Y, Z; int main() { cin>>A>>B>>C; cin>>X>>Y>>Z;
if(X > A) C -= (X - A); if(Y > B) C -= (Y - B); if(Z <= C) cout<<"It is a kind of magic"; else cout<<"There are no miracles in life";
return 0; } Notice that "Filling value” is THREE decimal places. Why always getting mle on #2 |
|