Maxlight

@Maxlight

Joined on May 8, 2021

  • 1 Further study on process switching Timer Interrupt is a non-cooperative approach to enforce process scheduling. To achieve this, the operating system relies on a hardware timer to generate periodic interrupts, which trigger process switching. When the timer interrupt occurs, the currently running process is halted, and control is transferred to the OS (kernel). And the scheduler determines whether the current process should continue or if another process should run. If a new process is selected, the OS saves the context (registers, program counter, stack pointer) of the current process and loads the context of the next process. 2 Basic concepts of terminal and shell image I use tmux to seperate the terminal. 2. The process is managed by the OS, not the terminal itself. Therefore, we can kill any process run on the OS in different terminal.
     Like  Bookmark
  • GCP 帳號 aaid-user05 [name=吳俊廷] aaid-user06 [name=韓欣劭] aaid-user07 [name=吳振榮] aaid-user08 [name=盧昱安] GCP 資訊 GCP project: tsmccareerhack2025-aaid-grp2 下載題目組提供的資料之 GCS bucket: careerhack2025-aaid-resource-bucket 供存放資料的 GCS bucket: tsmccareerhack2025-aaid-grp2-bucket
     Like  Bookmark
  • DP LCS #include <bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; string s1, s2; int dp[505][505]; int main(){ IOS cin >> s1 >> s2;
     Like 1 Bookmark
  • 富裕 -1s --1s --1s -2s -3s 清寒 孤兒 不要看上面的哈哈
     Like  Bookmark
  • 由於近日在 Mac 上執行 SDL2 的時候遇到一些問題,發現這問題是在 Mac 上才會有的,到 Linux 上反而就沒事了,因此我打算直接使用 Docker ,並且藉由 X11 把畫面投影在 Mac 上。 以下是我踩過很多坑之後得到的作法! Create a Docker container $ docker run ubuntu:18.04 $ docker ps -a 你可以藉由第一個指令創建一個 ubuntu 18.04 的 container ,並且用第二個指令看到他的 container ID 。 Enter Docker terminal $ docker start {container ID}
     Like  Bookmark
  • 相信大家都知道什麼是中位數吧,這題最直觀的方式就是針對每一個 window 去做排序,做完排序就可以找到每個 window 的中位數,但......這很花時間,這樣的時間複雜度是 $O((n - k +1) * klogk)$ ,會 TLE ,因此我們不能使用這個方法。 這題我們提供一個作法,也就是利用 multiset 去做優化,具體上怎麼做呢?我們來看看! 我們要做的就是維護兩個 multiset ,一個是包含中位數的左邊的 left ,另一個是中位數右邊的 right ,並且使 left 的 multiset 會指向我們的中位數,這樣一來我們就可以取 *left 當做我們的中位數,並且隨著 window 移動,我們也可以很快的刪除以及加入元素,這樣的複雜度就會是 $O((n - k + 1) * logk)$ ,就能順利的拿到這一題。 要記得 multiset 的底層是紅黑樹,因此在插入以及刪除都是 $O(logn)$ 。 這邊要注意一個點就是 multiset 在 erase 元素的時候如果是塞 multiset.erase(value) ,這樣會使整個容器內的 value 值都被刪掉,因此如果只要刪除某個 value 的其中一個值,記得是塞 iterator ,例如 multiset.erase(*left.begin()) 。 #include <bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     Like  Bookmark
  • Time Complexity Compare set map unordered_map 插入 $O(logn)$ $O(logn)$ $O(1)$
     Like  Bookmark
  • Problem PA CSES 1629 Movie Festival https://vjudge.net/problem/CSES-1629 Solution #include <bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define N 200005 #define int long long using namespace std;
     Like  Bookmark
  • 20230321 https://cpe.cse.nsysu.edu.tw/cpe/file/attendance/problemPdf/10035.pdf https://cpe.cse.nsysu.edu.tw/cpe/file/attendance/problemPdf/11824.pdf https://cpe.cse.nsysu.edu.tw/cpe/file/attendance/problemPdf/13055.pdf https://cpe.cse.nsysu.edu.tw/cpe/file/attendance/problemPdf/11240.pdf https://cpe.cse.nsysu.edu.tw/cpe/file/attendance/problemPdf/160.pdf https://cpe.cse.nsysu.edu.tw/cpe/file/attendance/problemPdf/1366.pdf https://cpe.cse.nsysu.edu.tw/cpe/file/attendance/problemPdf/11624.pdf https://vjudge.net/contest/593082
     Like  Bookmark
  • :::warning 這個題目我在做測試的時候主要在UBUNTU的環境,用mac的人要注意一下,mac沒有gdb,但有lldb(我不會用。 至於sanitizer的部分,在clang3.1之後應該都有。 ::: 這題的重點在於是否懂 Little Endian ,如果懂就結束了。 如果你不知道什麼是 Little Endian 就真的該打屁股了,上課都不認真,去二刷一遍 L紀的課再回來寫這題,我知道你懶得去找哪一部影片,看我多貼心連結我都給你了,趕快去二刷一下(或者有人可能是第一次看?)。 Alice code 一開始我們來看看 Alice 的程式
     Like 2 Bookmark
  • Code https://github.com/MaxWutw/snake $ git clone https://github.com/MaxWutw/snake.git 功能 按按鈕之後會頭尾交換 顯示題目出現ABCD四種蘋果 吃到錯誤的蘋果會顯示廣告 顯示RGB蘋果
     Like  Bookmark
  • 在這一題makefile可以看看助教給的<a href="https://hackmd.io/@cp2023/cp1-hw3-info#34-Tower-of-Hanoi">關係圖</a>,接著看看助教在作業給的最後一句,You need to implement two different functions in another C code and prepare a header file.,根據助教給的資料,以及TA hour助教說的東西,我自己的理解是這樣的,助教要我們提供三個.c檔,一個是主程式,也就是我們要call function的hw0304.c檔,一個是用迴圈實現的函式,一個是遞迴實現的函式,此外要我們寫一個header file,且該header file裡面會僅放一個函式的宣告,藉由將不同的程式揉在一起,來實踐不同的方式,我想這樣講可能有聽沒有懂,我來用我的資料實際示範一次。 首先我們會有三個檔案,分別是hw0304.c, hw0304-1.c, hw0304-2.c, hw0304.h,各個檔案的內容大概會長的像這樣(以下只是範例,但基本上大同小異)。 <strong>hw0304.c</strong> #include <stdio.h> #include <stdint.h> #include "hw0304.h" int main(){ printf("Please enter the disk number (2-20): "); int32_t n;
     Like  Bookmark
  • 學完物件導向程式設計後可以來了解重載運算子重載,operator overloading也可以叫做運算子覆載,或運算子多載,反正意思差不多,這裡就稱為重載運算子重載,至於為何要使用運算子重載呢?先來看一個例子: int main(void){ int a = 4, b = 6, c; c = a + b; std::cout << c; //output:10 } 這個例子中可以很清楚的看到我用一個「加號」將a和b相加,這當然沒問題,那下面這個例子呢? #include <iostream>
     Like  Bookmark
  • 簡介 LIS是要計算一個序列中最長的遞增子序列,例如 [10, 9, 2, 5, 3, 7, 101, 18] 這個序列中的最長遞增子序列可以是[2, 3, 7, 101],LIS的答案可以不為一,可能有很多種答案,因此我們要求的是他的最長長度。而我將會介紹$O(N^2)$和$O(NlogN)$的做法! $O(N^2)$的作法 我們可以直接窮舉先前每項數字的LIS,並去計算哪一種的長度最長。 定義 $dp[i]$ 表示以$i$為結尾的最長遞增子序列。 因此要計算 $dp[i]$ 需要去檢查小於$i$的所有位置,假設$j$是我們要去檢查的位置,如果 $j < i$ 並且 $arr[j] > arr[i]$ 則可以把 $arr_j$ 為結尾的LIS接上來,最長遞增子序列的值就會變成 $dp[j] + 1$,當然啦我們是要求最長的,所以即使有非常多種答案,我們最終要取最好的,因此我們可以得到轉移式
     Like  Bookmark
  • Sparse Table是一種資料結構,在$O(nlogn)$的時間複雜度做預處理,並可以進行$O(1)$的查詢,Sparse Table常被用在RMQ的題目,可以視題目需求更改$min()$、$max()$、$gcd()$、$sum()$。其中預處理的方式會使用到倍增法(Binary Lifting),由於建表需要花$O(nlogn)$,所以如果要使用Sparse Table必須在不帶修改的題目才比較合適。 找區間MAX(<a href="https://zerojudge.tw/ShowProblem?problemid=d539">zerojudge d539</a>) :::success 給一個數列$T1,T2,T3....Tn$,求$Ta$到$Tb$之間(涵蓋$Ta$、$Tb$)的最大值。 範例輸入 10 3 2 4 5 6 8 1 2 9 7 7
     Like  Bookmark
  • 304張維恩 可以稍微自我介紹一下嗎? 資料科學在做什麼? 需要具備哪些能力? 我看你有做過一些資料分析的專案,說明你比較特別的作品,並稍微分享。 有沒有跟同學合作一些專案? 黃柏豪 請坐 柏豪嗎?
     Like  Bookmark
  • Wiwiho:https://cp.wiwiho.me/lessons/ 從零開始的演算法競賽入門教學:https://emanlaicepsa.github.io/ 南一中競程講義:https://hackmd.io/@sa072686/cp/%2F%40sa072686%2FBkTJ0imPB 成大競程:https://hackmd.io/@nckuacm/ryLIV6BYI/%2F%40nckuacm%2FBJD15vyrI?fbclid=IwAR3ccRM0_mELCt_P3F3AkyS_gWteRRaqJH1sR7HoJ65ewArZY3RRd8x__dw CS cheat sheet:https://github.com/OmeletWithoutEgg/ckiseki/blob/master/pdf/codebook.pdf
     Like 2 Bookmark
  • Default code v1 #include <iostream> #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define out cout << '\n'; #define int long long #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma comment(linker, "/stack:200000000") signed main(){ IOS
     Like  Bookmark
  • 終於到了我心中的大大大大魔王,這是我目前學到最難做最難想的演算法,運用到的許多遞迴的觀念還有分治演算法的概念,所以對遞迴和分治法要夠熟來解決dp才能得心應手。 但dp的難度真的太高,所以這邊只會紀錄最基礎的部分。 一般如果要進行費氏數列的運算會利用遞迴做,f(n-1)+f(n-2) #include <iostream> using namespace std; int f(int n){ if(n == 1 || n == 2) return 1; return f(n-1)+f(n-2); }
     Like  Bookmark
  • from vpython import * """ 1. 參數設定, 設定變數及初始值 """ m = 1 # 小球質量 size = 0.2 # 小球半徑 L = 5 # 繩長 theta = radians(30) # 繩子與鉛垂線夾角 R = L*sin(theta) # 錐動擺半徑
     Like  Bookmark