Posts

Post not yet marked as solved
19 Replies
7.4k Views
Earlier my C++ was working on Xcode 13 versions but when updated to Xcode 14 it is now returning various errors (seems memory errors). The same code is compiling on other platforms such as windows and in online compilers. Error:- 0 0x1029141a0 __assert_rtn + 140 1 0x10279ba8c mach_o::relocatable::Parser<arm64>::parse(mach_o::relocatable::ParserOptions const&) + 4536 2 0x10276dd38 mach_o::relocatable::Parser<arm64>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 148 3 0x1027d64ac ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 1468 4 0x1027d9360 ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 56 5 0x188b381f4 _dispatch_client_callout2 + 20 6 0x188b4b954 _dispatch_apply_invoke + 224 7 0x188b381b4 _dispatch_client_callout + 20 8 0x188b49a04 _dispatch_root_queue_drain + 680 9 0x188b4a104 _dispatch_worker_thread2 + 164 10 0x188cf8324 _pthread_wqthread + 228 A linker snapshot was created at: /tmp/solution-2022-09-14-105028.ld-snapshot ld: Assertion failed: (_file->_atomsArrayCount == computedAtomCount && "more atoms allocated than expected"), function parse, file macho_relocatable_file.cpp, line 2061. collect2: error: ld returned 1 exit status Code : #include<bits/stdc++.h> using namespace std; #define int long long int #define vi vector<int> #define pii pair<int,int> #define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define all(x) begin(x),end(x) #define rep(x,a,b) for(int x = a;x<(b+1);x++) #define F first #define S second const long long inf = 1e18, mod = 1e9 + 7; int pw(int x, int y, int p = mod) { if (y == 0) return 1; if (y == 1) return x; int res = pw(x, y / 2); if (y & 1) return ((res * res) % p * x) % p; return (res * res) % p; } int nu(vi & suff, int l, int r){ int n = suff.size(); int ans = suff[l] - ((r<n-1)?suff[r+1]:0); int di = pw(10, n-r-1); ans = (ans*pw(di, mod-2))%mod; return ans; } void test_case() { string s; cin>>s; int n = s.size(); int w,m; cin>>w>>m; vi suff(n+1,0); suff[n] = s[n-1]-'0'; for(int i = n-2;i>=0;i--){ suff[i+1] = ((s[i]-'0')*pw(10,n-i-1) + suff[i+2])%mod; } map<int, pii> mp; for(int i = n-w+1;i>0;i--){ int t = nu(suff, i, i+w-1)%9; mp[t] = {i, (mp.count(t)>0?mp[t].F:0)}; } while(m--){ int l,r,k; cin>>l>>r>>k; int ans1 = inf, ans2 = inf; rep(j,0,8){ int l1 = mp[j].F; int v = nu(suff, l, r); int p = (j*v)%9; int x = (k-p+9)%9; int l2 = mp[x].F; if(l2==l1) l2 = mp[x].S; if(l1>0 and l2>0){ if(l1<ans1){ ans1 = l1; ans2 = l2; }else if(l1==ans1){ ans2 = min(ans2, l2); } } } if(ans1<inf and ans2<inf){ cout<<ans1<<" "<<ans2<<endl; } else cout<<"-1 -1"<<endl; } } int32_t main() { fast(); int tt = 1; cin >> tt; for(int i = 1;i<=tt;i++) { // cout<<"Case #"<<i<<": "; test_case(); } return 0; } Give input to code: 5 1003004 4 1 1 2 1 179572007 4 2 2 7 3 2 7 4 111 2 1 2 2 6 0000 1 2 1 4 0 1 4 1 484 1 5 2 2 0 2 3 7 1 2 5 3 3 8 2 2 6
Posted
by fanick.
Last updated
.