tmting39
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 歐拉迴路 [TOC] 一條洽走過所有邊一次的路徑稱為歐拉路徑,若起點與終點相同則稱為歐拉迴路。 # 觀察 若一張無向圖存在歐拉迴路,則圖為連通的且每個點的度數皆為偶數,必要性顯然,每個點出去的次數都等於進入的次數。故我們在此證明必要性: 選定一個起點,我們一定可以找到一條回到起點的路徑(Trivial),若把這些邊拔掉,圖上每個點的度數依然為偶數,則對於此路徑上的任一個節點我們都可以在找到一條回到該節點的路徑,如此重複並把所有路徑相加便會得到歐拉迴路。 歐拉路徑只是把歐拉迴路再拔掉一條邊。 # 實作 先隨便走直到走回起點(即走到沒有路),把最後一條邊加入答案,往前看上一個節點,再一直走直到回到自己。 會發現,這不就是DFS的後序嗎,因此code如下: ```cpp= void dfs(int pos){ while(!g[pos].empty()){ int i=g[pos].front(); g[pos].erase(i); g[i].erase(pos); dfs(i); } ans.push_back(pos); } ``` 注意這是紀錄路徑上的點的寫法,若要紀錄邊要再修改。 # 有向圖 有向圖存在非迴路的歐拉路徑的充要條件: * 連通圖 * 起點的出邊比入邊多一條 * 終點的入邊比出邊多一條 * 其餘的點兩種邊一樣多 找解的方式與無向圖相同 # K筆畫 對於每個連通塊,新增一個節點,並把所有奇點都連到這個點。照著原方法做,最後再把這個節點刪掉。 # 題目 ## [Mail Delivery](https://cses.fi/problemset/task/1691/) 無向圖裸題 --- ## [Fair Share](https://codeforces.com/problemset/problem/1634/E) :::spoiler 解法: 對每一個陣列和每一種數字各建一個點,將陣列節點與陣列內的數字個連一條邊,條件轉換如下: * 每個陣列有一半L一半R$\Longrightarrow$每個陣列節點的入邊和出邊數量一樣 * 每個數字有一半L一半R$\Longrightarrow$每個數字節點的入邊和出邊數量一樣 找歐拉迴路就好 ::: --- ## [Teleporters Path](https://cses.fi/problemset/task/1693/) 有向圖裸題 --- ## [P1341 无序字母对](https://www.luogu.com.cn/problem/P1341) [洛谷 P1127 词链](https://www.luogu.com.cn/problem/P1127)和[洛谷 P1333 瑞瑞的木棍](https://www.luogu.com.cn/problem/P1333)也是類似的題目 :::spoiler code: ```cpp= #include<bits/stdc++.h> using namespace std; vector<char> ans; vector<set<int>> g(52); vector<int> doo(52); void dfs(int pos){ while(!g[pos].empty()){ int i=*g[pos].begin(); g[pos].erase(i); g[i].erase(pos); dfs(i); } ans.push_back(pos>=26? 'a'+(pos-26):'A'+pos); } int main(){ int n; cin>>n; for(int i=0;i<n;i++){ string s; int a,b; cin>>s; if(s[0]<='Z') a=s[0]-'A'; else{ a=s[0]-'a'; a+=26; } if(s[1]<='Z'){ b=s[1]-'A'; } else{ b=s[1]-'a'; b+=26; } g[a].insert(b); g[b].insert(a); doo[a]++; doo[b]++; } int cnt=0; for(int i:doo) if(i%2==1) cnt++; if(cnt>2){ cout<<"No Solution"<<endl; return 0; } for(int i=0;i<52;i++){ if(!g[i].empty()&&(cnt==0||doo[i]%2==1)){ dfs(i); break; } } reverse(ans.begin(),ans.end()); for(auto i:ans)cout<<i; cout<<endl; return 0; } ``` ::: --- ## [D. Tanya and Password](https://codeforces.com/problemset/problem/508/D) :::spoiler 提示: 就只是上面那一題的延伸而已,因此思考怎麼變成上面那一題的形式 ::: [題解](https://codeforces.com/blog/entry/16048?locale=en) --- ## [Senior Postmen](https://oj.uz/problem/view/BOI14_postmen) [題解](https://github.com/boi-2014/tasks/blob/master/solutions/analysis/postmen.tex) --- # reference 2023 IOI Camp

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully