2026年8月17日 星期一

Frequency comb (頻率梳)

 A frequency comb or spectral comb is represented by a spectrum made of discrete, stable and regularly spaced spectral lines. In optics, a frequency comb can be generated by certain laser sources.

A number of mechanisms exist for obtaining an optical frequency comb, including periodic modulation (in amplitude and/or phase) of a continuous-wave laser, four-wave mixing in nonlinear media, or stabilization of the pulse train generated by a mode-locked laser. Much work has been devoted to this last mechanism, which was developed around the turn of the 21st century and ultimately led to one half of the Nobel Prize in Physics being shared by John L. Hall and Theodor W. Hänsch in 2005.

頻率梳(frequency comb)或光譜梳(spectral comb)是由離散、穩定且具備等間距光譜線所組成的光譜。在光學中,頻率梳可以透過特定的雷射源來產生。

獲得光學頻率梳的機制有多種,包括對連續波雷射進行週期性調變(振幅和/或相位)、在非線性介質中進行四波混頻,或是對鎖模雷射所產生的脈衝序列進行穩頻。許多研究都投入在最後這項機制上;該機制於 21 世紀初發展成熟,並最終促使約翰·霍爾(John L. Hall)與特奧多爾·亨施(Theodor W. Hänsch)共同榮獲 2005 年諾貝爾物理學獎的一半獎項。

2026年4月29日 星期三

World Action Models 世界行動模型

 Current top-performing Vision-Language-Action models are good at understanding and generalizing across different semantic concepts, but they tend to fall short when encountering unfamiliar physical movements in new environments. This paper presents DreamZero, a new type of model called a World Action Model, which is built on top of a pre-trained video diffusion system. Rather than following the VLA approach, DreamZero learns how the physical world works by predicting what future states and actions will look like, treating video as a rich signal for how things change over time. By learning from both video and action data together, the model can pick up a wide variety of skills from mixed and diverse robot datasets without needing lots of repeated examples. In real-world robot tests, this leads to more than double the performance gains on new tasks and settings compared to leading VLA methods. The team also made significant engineering and algorithmic improvements that allow this large 14-billion-parameter model to run fast enough for real-time robot control at 7 frames per second. Beyond that, the paper shows two ways the model can transfer across different robot bodies: using video demonstrations from other robots or humans brings over a 42% relative boost on unseen tasks with only 10 to 20 minutes of data; and the model can adapt to an entirely new robot body with just 30 minutes of free-play data, while still performing well on tasks it has never explicitly trained for.

目前頂尖的視覺語言動作模型(VLA)擅長跨語義概念的理解與泛化,但在面對新環境中陌生的物理動作時往往表現不佳。本論文提出 DreamZero,一種新型模型,稱為世界動作模型(WAM),建構於預訓練的視頻擴散系統之上。與 VLA 的方式不同,DreamZero 透過預測未來的世界狀態與動作來學習物理世界的運作規律,將視頻視為世界隨時間演變的豐富訊號。藉由同時從視頻與動作資料中共同學習,該模型能夠從多樣化的異質機器人資料集中習得各式各樣的技能,而無需大量重複性示範。在真實機器人實驗中,相較於頂尖的 VLA 方法,DreamZero 在新任務與新環境上的表現提升超過兩倍。研究團隊同時在演算法與系統層面進行了大幅優化,使這個擁有 140 億參數的大型模型能夠以每秒 7 幀的速度執行實時機器人控制。此外,本論文展示了兩種跨機器人本體的遷移方式:利用來自其他機器人或人類的純視頻示範,僅需 10 至 20 分鐘的資料便能在未見任務上帶來超過 42% 的相對性能提升;更令人驚喜的是,模型僅需 30 分鐘的自由探索資料即可適應全新的機器人本體,同時仍能在從未明確訓練過的任務上保持出色的零樣本泛化能力。


2025年5月2日 星期五

UVa _ 10004 _ Bicoloring

 def is_bicolorable(adj_list, n):

    for start_node in range(n):

        color = [-1] * n        

        if color[start_node] != -1:

            continue

        # Iterative approach prevents stack overflow for large graphs

        stack = [(start_node, 0)] 

        color[start_node] = 0

        while stack:

            node, node_color = stack.pop()

            next_color = 1 - node_color  # Toggle between 0 and 1

            for neighbor in adj_list[node]:

                if color[neighbor] == -1:

                    color[neighbor] = next_color

                    stack.append((neighbor, next_color))

                elif color[neighbor] == node_color:  # Same color conflict

                    return False

    return True

while True:

    n = int(input())

    if n == 0:

        break

    m = int(input())

    adj_list = [[] for _ in range(n)] # Build adjacency list 

    for _ in range(m):

        a, b = map(int, input().split())

        adj_list[a].append(b)

        adj_list[b].append(a)

    print("BICOLORABLE." if is_bicolorable(adj_list, n) else "NOT BICOLORABLE.")

2025年4月12日 星期六

UVa _ 00532 _ Dungeon Master

 #include <iostream>

#include <queue>

#include <cstdio>

#include <cstring>

using namespace std;

const int MAXN = 32;

char dungeon[MAXN][MAXN][MAXN];

int Distance[MAXN][MAXN][MAXN];

int L, R, C;

const int direction[6][3] = {{-1, 0, 0}, {1, 0, 0}, {0, -1, 0},

                                     {0, 1, 0}, {0, 0, -1}, {0, 0, 1}};

struct point_type { int x; int y; int z; };

int BFS(int start_i, int start_j, int start_k) {

    // keypoint: Init Distance (-1 = not visited)

    for (int i = 0; i < L; ++i)

        for (int j = 0; j < R; ++j)

            for (int k = 0; k < C; ++k)

                Distance[i][j][k] = -1;

    // keypoint: BFS queue

    queue<point_type> q;

    q.push({start_i, start_j, start_k});

    Distance[start_i][start_j][start_k] = 0;

    while (!q.empty()) {

        point_type cur = q.front();

        q.pop();

        // keypoint: Found end

        if (dungeon[cur.x][cur.y][cur.z] == 'E')

            return Distance[cur.x][cur.y][cur.z];

        for (int i = 0; i < 6; ++i) {

            point_type nxt = {cur.x + direction[i][0], cur.y + direction[i][1], cur.z + direction[i][2]};

            // keypoint: Boundary check

            if (nxt.x < 0 || nxt.x >= L || nxt.y < 0 || nxt.y >= R || nxt.z < 0 || nxt.z >= C) continue;

            // keypoint: Wall check

            if (dungeon[nxt.x][nxt.y][nxt.z] == '#') continue;

            // keypoint: Visited check

            if (Distance[nxt.x][nxt.y][nxt.z] != -1) continue;

            Distance[nxt.x][nxt.y][nxt.z] = Distance[cur.x][cur.y][cur.z] + 1;

            q.push(nxt);

        }

    }

    return -1; // keypoint: No path

}

int main() {

    while (scanf("%d%d%d", &L, &R, &C) == 3) {

        if (!L && !R && !C) break;

        int start_i, start_j, start_k;

        for (int i = 0; i < L; ++i)

            for (int j = 0; j < R; ++j) {

                scanf("%s", dungeon[i][j]);

                for (int k = 0; k < C; ++k)

                    if (dungeon[i][j][k] == 'S')

                        start_i = i, start_j = j, start_k = k;

            }

        int minute = BFS(start_i, start_j, start_k);

        if (minute != -1)

            printf("Escaped in %d minute(s).\n", minute);

        else

            printf("Trapped!\n");

    }

    return 0;

}

2025年3月28日 星期五

UVa _11456 _ Trainsorting

 #include <iostream>

#include <vector>

using namespace std;

int findLongestSymmetricSubsequence(int sequenceLength) {

    // Create mirrored train sequence

    vector<int> symmetricSequence(sequenceLength * 2);

    // Track length of increasing subsequence for each position

    vector<int> subsequenceLengths(sequenceLength * 2, 1);

    int maxSubsequenceLength = 0;

    // Read and mirror the sequence

    for (int i = 0; i < sequenceLength; ++i) {

        int trainCarValue;

        cin >> trainCarValue;

        symmetricSequence[sequenceLength + i] = symmetricSequence[sequenceLength - i - 1] = trainCarValue;

    }

    // Find longest increasing subsequence

    for (int currentIndex = 0; currentIndex < sequenceLength * 2; ++currentIndex) {

        for (int prevIndex = 0; prevIndex < currentIndex; ++prevIndex) {

            // If current element is larger than previous, update subsequence length

            if (symmetricSequence[currentIndex] > symmetricSequence[prevIndex]) {

                subsequenceLengths[currentIndex] = max(

                    subsequenceLengths[currentIndex], 

                    subsequenceLengths[prevIndex] + 1

                );

            }

            // Track maximum subsequence length

            maxSubsequenceLength = max(maxSubsequenceLength, subsequenceLengths[currentIndex]);

        }

    }


    return maxSubsequenceLength;

}


int main() {

    // Optimize input/output performance

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);


    int numberOfTestCases;

    cin >> numberOfTestCases;


    // Process each test case

    while (numberOfTestCases--) {

        int trainLength;

        cin >> trainLength;


        // Solve and output result for current test case

        cout << findLongestSymmetricSubsequence(trainLength) << "\n";

    }


    return 0;

}

2025年3月27日 星期四

UVa _ 10336 _ Rank the Languages

 import sys

# Constants

MX = 10000

class Type:

    def __init__(self, id=None, value=0):

        self.id = id

        self.value = value

def comp(a):

    # Comparison function for sorting ranks

    # Primary sort: descending order of value (using negative to achieve descending)

    # Secondary sort: ascending order of id (in case of equal values)

    # Useful for ranking components by size and then by identifier

    return (-a.value, a.id)

def init(h, w):

    # Initialize a list of Type objects with default values

    # Creates an empty data structure of specified dimensions

    # Useful for pre-allocating space for graph-related data structures

    return [Type() for _ in range(h * w)]

def set_rank(ranks, c, r):

    for rank in ranks:

        if rank.id == c:

            rank.value += r

            return    

    new_rank = Type(id=c, value=r)

    ranks.append(new_rank)

def dfs_visit(graph, a, b, h, w):

    # Capturing the original color/type of the current cell before modification

    temp_c = graph[a][b]

    # label v as discovered

    # Mark the current cell as 'visited' to prevent re-exploration and avoid infinite recursion

    graph[a][b] = 'G'

    

    # Directional movements represent the possible traversal directions

    # These coordinates allow checking adjacent cells (left, up, right, down)

    dr = [0, -1, 0, 1]

    dc = [-1, 0, 1, 0]

    # for all directed edges from v to w that are in G.adjacentEdges(v) do

    # Iterate through all four possible adjacent directions

    for i in range(4):

        r = dr[i] + a

        c = dc[i] + b

        # if vertex w is not labeled as discovered then

        # Check if the adjacent cell is within graph boundaries and of the same color/type

        if (0 <= r < h and 0 <= c < w and 

            graph[r][c] == temp_c):

            # recursively call DFS(G, w)

            # Explore the connected component by recursively visiting adjacent cells

            dfs_visit(graph, r, c, h, w)

    # Mark the cell as completely explored to distinguish from undiscovered cells

    graph[a][b] = 'B'


def dfs(graph, h, w):

    # Initialize a list to store ranked components

    ranks = []

    # for all directed edges from v to w that are in G.adjacentEdges(v) do

    # Traverse through entire graph to find and explore connected components

    for i in range(h):

        for j in range(w): 

            # if vertex w is not labeled as discovered then

            # Check if the current cell hasn't been explored in previous DFS calls

            if graph[i][j] not in ['G', 'B']: 

                # Assign initial rank to the newly discovered component

                set_rank(ranks, graph[i][j], 1)  

                # recursively call DFS(G, w)

                # Start DFS from this undiscovered cell to explore its entire component

                dfs_visit(graph, i, j, h, w)

    return ranks


def process_world(h, w, graph_input):

    # Convert input to 2D list for easier manipulation

    graph = [list(row) for row in graph_input]

    # Perform depth-first search to identify and rank components

    ranks = dfs(graph, h, w)

    # Sort ranks in descending order of component size, with secondary sorting by component ID

    ranks.sort(key=comp)

    return ranks


test_cases = int(input())

cases = 0


for _ in range(test_cases):

    h, w = map(int, input().split())

    graph_input = [input() for _ in range(h)]

    cases += 1

    ranks = process_world(h, w, graph_input)

    print(f"World #{cases}")

    for rank in ranks:

        print(f"{rank.id}: {rank.value}")

2025年2月14日 星期五

SMASHIN' SCOPE

 SMASHIN’ SCOPE is an acronym, created by Tony Buzan, to assist with memorization:

  • Synesthesia/Sensuality 
  • Movement
  • Association
  • Sexuality
  • Humor
  • Imagination
  • Numbers
  • Symbolism
  • Color
  • Order and/or Sequence
  • Positive Images
  • Exaggeration

2022年3月15日 星期二

thread APIs for C/C++ : Creation & Synchronization

Threads share one address space (that is, they can all examine and modify the same variables). On the other hand, each thread has its own registers and execution stack pointer(執行堆疊), and perhaps private memory.

#include <iostream>

#include <condition_variable> // condition variable 條件變量

#include <thread>

#include <chrono>

 

std::condition_variable cv;

std::mutex cv_m;  // This mutex is used for three purposes:

                              // 1) to synchronize accesses to i

                              // 2) to synchronize accesses to std::cerr

                              // 3) for the condition variable cv

int i = 0;

void waits() //used by t1,t2 & t3

{

    std::unique_lock<std::mutex> lk(cv_m);

    std::cerr << "Waiting... \n";

    cv.wait(lk, []{return i == 1;}); //wait(lock)

    std::cerr << "...finished waiting. i == 1\n";

}

void signals()// used by thread t4

{

    std::this_thread::sleep_for(std::chrono::seconds(5));

    {

        std::lock_guard<std::mutex> lk(cv_m);

        std::cerr << "Notifying...\n";

    }

    cv.notify_all();

 

    std::this_thread::sleep_for(std::chrono::seconds(5));

    {

        std::lock_guard<std::mutex> lk(cv_m);

        i = 1;

        std::cerr << "Notifying again...\n";

    }

    cv.notify_all();

}

 

int main()

{

    std::thread t1(waits), t2(waits), t3(waits), t4(signals);

    t1.join(); 

    t2.join(); 

    t3.join();

    t4.join();

}

/*

Produce results in sequence: 

1.thread t1,t2,t3 are waiting

Waiting...

Waiting...

Waiting...

2. broadcast after 5 s

Notifying...

3. broadcast after another 5 s

Notifying again...

4. thread t1,t2,t3 are unlocked

...finished waiting. i == 1

...finished waiting. i == 1

...finished waiting. i == 1

*/



2021年9月22日 星期三

My second Java Program - multithreading - SLOC=56

package waitNotify;

class Badminton { // 在羽球類別中,設定羽毛球物件的屬性和方法

   private boolean isShooting = false;

   public synchronized void sShuttlecock(int tNo) {

   while (isShooting) {

   try {

   wait();

   } catch (InterruptedException e) {}

   }

   System.out.println("射出第"+tNo+" 顆羽球");

   isShooting = true;

   notify();

   }

   public synchronized void hShuttlecock(int aNo) {

   while (!isShooting) {

   try {

   wait();

   } catch (InterruptedException e) {}

   }

   System.out.println("擊回第"+aNo+" 顆羽球");

   isShooting = false;

   notify();

   }

}

class Shooting implements Runnable{

Badminton shuttlecock;

Shooting (Badminton shuttlecock){

this.shuttlecock = shuttlecock;

}

public void run() {

for (int i = 1; i <= 5; i++) {

shuttlecock.sShuttlecock(i);

}

}

}

class Hit implements Runnable{

Badminton shuttlecock;

Hit (Badminton shuttlecock){

this.shuttlecock = shuttlecock;

}

public void run() {

for (int i = 1; i <= 5; i++) {

shuttlecock.hShuttlecock(i);

}

}

}

public class WaitNotify {

public static void main(String[] args) {

// TODO Auto-generated method stub

Badminton shuttlecock = new Badminton(); 

Thread machine = new Thread(new Shooting(shuttlecock));

Thread hitter = new Thread(new Hit(shuttlecock));

machine.start();

hitter.start();

}

}


2021年8月19日 星期四

My first Java program

package ex01;

import java.util.Scanner;

public class Hello {

      

      public static void main (String[] args) {

            Scanner scn  =  new Scanner(System.in);

            System.out.print("Please enter name:");

            String strName = scn.next(); /* declare a string variable named "strName", use scn.next() method to get what string a user entered, then assign to "strName". */

            System.out.println("Hi !" + strName + ",Welcome to Java world!");

            scn.close();

      }


}


2019年1月6日 星期日

GitHub simple Guide

1. Create a Repository : Click+ , Name & ReadMe

2. Create a Branch : Master & Feature

3. Make and commit changes : ReadMe-Edits & Why Changes

4. Open a Pull Request : Differences

5. Merge your Pull Request : Merge & Delete branch

''Pull Request"

2018年4月24日 星期二

GRE 單字 2018.4.25

1.forbear from laughing out loud 忍住笑出來

2.boorish/rude/impolite behaviour 無禮的行為

3.propitious/favourable/opportune moment/environment 有利的時機/環境

4.contentious/controversial/ambivalent debate 有爭議的辯論

5.emulate/imitate/copy one's success 效法某人的成功

2014年12月26日 星期五

常用一字多義的35個英文動詞

1.go
2.come
3.take
4.give
5.pull
6.push
7. be (present:is/are;past:was/were)

8.run
9.grow
10.bring
11.get
12.put
13.drive
14.make

15.turn
16.keep
17.throw
18.carry
19.help
20. do
21.have

22.break
23.hit
24.cut
25.see
26.know
27.say
28.tell

29.show
30.think
31.feel
32.listen
33.speak
34.read
35.write

2014年4月26日 星期六

上帝粒子---希格斯玻色子

        牛頓力學成功地解釋我們生活中周遭的大小事物,舉凡行星、火箭到我們生活中經驗的慣性原理,無一不在牛頓三大運動定律的囊括範圍裡。而其中,又以我們從國中就開始熟知的物體受力與其加速度的關係最具代表性,並且簡潔清楚的方程式表達成 F=ma,在這裡,F代表的是物體所受的合力,m為質量,a為加速度。在我們處理的問題中,物體的質量往往是已知的,我們毫無疑問的使用這個參數。然而,對科學家而言,卻不禁要問質量從何而來呢為什麼會有質量

        
這個問題,實際上應起源於解釋現今大小物質的基本粒子及三種基本力(強力、電磁力及弱力)的理論-標準模型中。在標準模型中,我們區分基本粒子為費米子及玻色子。而費米子就是組成物質的粒子,玻色子則負責傳遞各種作用力。回到原問題,事實上,質量來自許多不同的機制。物理學家已建構了關於質量的初步理論,理論中的關鍵,它是一種遍布於宇宙各角落的場,稱為希格斯場。而基本粒子就是透過與希格斯場的交互作用而擁有質量。打個比方,充滿希格斯場的空間,就好像充滿小孩子的海灘,通過這個區域的一個粒子,就好像來了一個冰淇淋小販….,有趣的事發生了因為孩子們會擁上和他互動,所以他的移動就會慢下來,就好像獲得了質量一樣。而所謂的希格斯玻色子即為希格斯場的振動。這就好像我們認知中電磁場量子化後成為光子,用以解釋光電效應和黑體輻射等。

        在我們知道了什麼是希格斯玻色子後,接著,下一個問題是實際上,希格斯粒子存不存在呢?這是一個極為重要的基礎物理問題。物理學者花費四十多年時間尋找它。至今為止,全世界最昂貴、最複雜的實驗設施之一,大型強子對撞機(LHC),其建成的主要目的之一就是尋找與觀察希格斯玻色子與其它基本粒子。時至今日,歐洲核子研究組織,暫時確認存在具有部分性質的希格斯玻色子。而首先提出希格斯場理論的彼得.希格斯,因為解釋次原子粒子質量的生成機制,促進了人類對這方面的理解,在2013年獲得諾貝爾物理獎。

   最後,假使人類真的完整理解了質量的起源,它會有哪些影響呢?顯而易見的,透過希格斯機制,人類可以自行製造質量,有如上帝創生行星、恆星一般,這也是為什麼希格斯粒子稱為上帝粒子的原因。屆時也許能製造個適合人類居住的星球也說不定。當然,根據愛因斯坦的質能方程式,首要的條件,應是找尋並利用現存在宇宙中的其他能源,以供應產生製造質量的可能。再者,人類本身也具有質量。因此,如果能夠配合利用現今的生物複製技術的話,現在科幻電影所常見的量子傳輸或許也將能夠實現。

2014年4月25日 星期五

下一個台灣諾貝爾獎得主?


   
    近年來,台灣大學入學方式的多元化,讓莘莘學子能夠選擇以更多的方式入學,有別過往僅能透過單一且龐大內容的考試。從以前的聯考時代,到後來區分出學科能力測驗以及指定科目考試,也隨著教材的不同和一些社會因素,而讓學生在兩者間的投入取捨上有些差異。其中,越來越多的學生選擇以學科能力測驗的管道入學,同時,各大學為了提前招生,也減少了指定考科入學的名額。因此,學生在面臨這樣的取才制度下,不少學生開始將學習的重心和時間放在投資報酬率較高的共同科目上,相形之下,日新又新的科學新知在每科僅佔少數比分的考題之下,便顯得乏人問津,其正視的程度不復以往。


       舉現行高一的物理教材為例,加入了許多高能物理(宇宙論及基本粒子)及近代物理(狹義相對論及量子力學)的內容作為新教材,卻仍有不少老師認為,學測的內容與國中教材大同小異,大多為古典物理的題材,不用花太多心思準備。事實上,現今我國及世界科技發展之趨,無一不是奠基在紮實的科學知識上。舉凡手機、觸控面板、數位相機乃至光纖網路,甚至是你我手邊的悠遊卡等等,其底層都有一定的背景知識及物理原理。而有了這些背景知識也才能更進一步地探討工程上研發。然而,現今這樣偏離正軌教育趨勢,不但大大扼殺了學生求知的興趣,也可能降低了未來國家科技發展的競爭力。引用一句華碩電腦董事長施崇棠在台大校園徵才博覽會所說過的話:「應該回去把基本功電磁學再念20~30遍」,由此可知,科學知識所涵蓋的不僅是高深的研究而已,在業界的用途和影響更是隨處可見。


      當然,不可諱言的,考試為必要之惡。這也是引領學生學習取向的一個很重要的因素。在這樣的前提之下,語文能力和數學必然是上了大學之後最重要的基礎。現實面來說,學生面臨的第一個關卡也一定是學科能力測驗,因此,我們不能告訴學生在這些共同科目就應該要因此失守。不過,優秀及聰明的學生應該更加明白,真的能夠讓自己勝出而更早更順利進入大學生活的重點,應是緊鄰學測後各校甄試。

       有了這樣的認知後,學生的顧念除了念好書以外,平時也應該培養一定的科學素養及興趣。無論是物理、化學、生物或是地球科學,深入地說,每一個學科都有一個很長很遠的故事;博覽而言,每一個領域其實都是息息相關、環環相扣。而現今所有的知識也無非都是濫觴於自然科學。1986年,台灣知名化學家李遠哲,因首先以分子角度來研究化學反應的動力學,而與達德利.赫施巴赫及約翰.波拉尼共獲諾貝爾化學獎,是第一位獲得諾貝爾獎的臺灣人。2014年3月,台灣籍物理學家郭兆林,負責設計監測儀器,以偵測物質運動時造成曲率變化的重力波,證實大霹靂理論的預測。此發現被認為拿到諾貝爾獎的聖杯,屆時可能為台灣第一位諾貝爾物理獎得主。這些例子都不但說明了台灣科學教育的成功,也強調讀書時興趣的重要。考試並非衡量一切的依據。正值學習關鍵時刻的你,倘若打好高中科普基礎,你能說自己沒有可能是下一個諾貝爾獎得主嗎?