ReTai-Hieu's blog

By ReTai-Hieu, history, 22 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.

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

| Write comment?
»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

if this isn't fake i will never use a mac.

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It's not fake LOL, I just used this "feature" on macOS 13.0.1.

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can confirm, it did restart when I compiled on sublime aswell xD

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Actually, this may be fake. On my mac, when a program asks for a very large memory( I’ve just tested, for about 50 GB), it will be killed by the OS. Your experience may be because you’ve changed the settings, or you are running many programs, so your OS can’t deal with the situation. Then the OS crashed because there isn’t enough memory. Finally, it restart automatically :-(.

    • »
      »
      »
      22 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      i use macbook air m1 with 8gb ram, may be m1 is the reason

    • »
      »
      »
      22 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You should use gcc compiler not clang.

»
22 months ago, # |
  Vote: I like it +9 Vote: I do not like it

it's not a bug, it's a feature for Apple computers to refuse to run anything that is not written in Swift (or Objective-C)

»
22 months ago, # |
Rev. 2   Vote: I like it +12 Vote: I do not like it

Instead of having a +10 minutes MLE penalty, now you will only have a +5 minutes penalty for restarting your mac. fair enough!

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

However, on my mac, the program with maxN=1e5+10 works normally. It seems that my computer will automatically kill programs which require too much memory, as I saw [1] 8735 killed /Users/…/xxx in the terminal when I ran a program.

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    In addition, my computer has an 8GB physical memory. Maybe situations will be different on devices with a smaller memory.

»
22 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Use Linux(arch btw) instead