ReTai-Hieu's blog

By ReTai-Hieu, history, 9 months ago, In English

my code

#include<bits/stdc++.h>
#define ii pair <int,int>
#define fi first
#define se second
#define int long long
#define double long double
#define endl '\n'
#define all(x) x.begin(), x.end()
using namespace std;

signed main(){
    //freopen("input.INP", "r", stdin);
    //freopen("output.OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << 100 << endl;
    return 0;
}

I use g++11 and vscode

That warning doesn't affect me if I run the code normally, but since I use CPH to compile it will stop my program and not run the test cases.

How to fix it

I dont know why, but the problem is I use Command Line Tools for Xcode 15. I have tried to install Command Line Tools for Xcode 14.3.1 then it works fine now

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By ReTai-Hieu, history, 10 months ago, In English
  • Vote: I like it
  • -4
  • Vote: I do not like it

By ReTai-Hieu, history, 15 months ago, In English

Watch this video first Video

#include<bits/stdc++.h>
#define ii pair <int,int>
#define fi first
#define se second
#define int long long
#define double long double
#define endl '\n'
using namespace std;

const int maxN = 5000;
// const int maxN = 1e5 + 10;

int dp[maxN][maxN];

signed main(){
    //freopen("input.INP", "r", stdin);
    //freopen("output.OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    return 0;
}

I use Macos Monterey 12.6.2, Command Line Tools for Xcode 14, and Homebrew GCC 12.2.0. When I declare the array too large, the machine will automatically restart. My question is is this a bug or a feature, because when I try it on Window 11 it still shows an error, not a restart. And as far as I know, when we restart the computer with code, we need admin permission sudo shutdown -r now but if we use this way, we don't need it.

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

By ReTai-Hieu, history, 19 months ago, In English

This morning, when I compile this code:

#include<bits/stdc++.h>
#define ii pair <int,int>
#define fi first
#define se second
#define int long long
#define double long double
#define endl '\n'
using namespace std;

map <ii, int> countPoint[10];
set <ii> listPair;

signed main(){
    //freopen("input.INP", "r", stdin);
    //freopen("output.OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // cout << countPoint[3][{1,3}];
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int a, b;
        cin >> a >> b;
        int count = 0;
        int x = a;
        int y = b;
        cout << "Point: " << a << " " << b << endl;
        if (a != 0 or b != 0){
            while(1){
                if (a > 0 and b >= 0){
                    break;
                }
                count++;
                int a0 = a, b0 = b;
                a = b0;
                b = -a0;
                cout << a << " " << b << endl; 
            }
            x = a;
            y = b;
            int gcd = __gcd(a,b);
            x /= gcd;
            y /= gcd;
        }
        countPoint[count][make_pair(x,y)]++;
        listPair.insert({x,y});
    }
    int ans = 0;
    for (auto i: listPair){
        ans += countPoint[0][i] * countPoint[1][i];
        ans += countPoint[1][i] * countPoint[2][i];
        ans += countPoint[2][i] * countPoint[3][i];
        ans += countPoint[3][i] * countPoint[0][i];
    }
    cout << ans;
    return 0;
}

I got this weird error

0  0x1003e81a0  __assert_rtn + 140
1  0x10026fa8c  mach_o::relocatable::Parser<arm64>::parse(mach_o::relocatable::ParserOptions const&) + 4536
2  0x100241d38  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  0x1002aa4ac  ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 1468
4  0x1002ad360  ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 56
5  0x1a67101f4  _dispatch_client_callout2 + 20
6  0x1a6724f8c  _dispatch_apply_invoke_and_wait + 224
7  0x1a672426c  _dispatch_apply_with_attr_f + 1152
8  0x1a672447c  dispatch_apply + 108
9  0x1002ad1f4  ld::tool::InputFiles::InputFiles(Options&) + 616
10  0x10022f6c0  main + 552
A linker snapshot was created at:
        /tmp/prac-2022-09-16-202054.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

I use MacOS Monterey, Command Line Tools for Xcode 14, and Homebrew GCC 12.2.0 If some of you got this you can do this to fix it

Full text and comments »

  • Vote: I like it
  • +16
  • Vote: I do not like it