Redleaf Li
    • 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
    • Publish Note

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

      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.
      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
    • Engagement control
    • 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 Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control 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
  • Publish Note

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

    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.
    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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    Day 4 上機題解 === ###### tags: `IONCAMP2019` [Johnny Johnny](https://pc2.tfcis.org/dev/index.php/problem/view/60/) --- first blood: **ToMmyDong** 題意為抓2個以上的數字,然後取gcd,在所有組合中取最大, 但是gcd一定是抓越多數字越小, 所以我們就窮舉所有兩兩的組合,然後取最大的gcd, 所有兩兩組合的最大值即為所求。 [老闆的時間](https://pc2.tfcis.org/dev/index.php/problem/view/78/) --- first blood: **Elliot** stringstream or 手動 ```cpp= while (getline(cin, buf)) { regex r("(\\d+)\\s+(\\d+)\\s+UTC(\\S+)"); // \\d 代表 0-9 的一個數字 vector<pair<int, int>> res; for (auto it = sregex_iterator(buf.begin(), buf.end(), r); it != sregex_iterator(); ++it) { int h = stoi(it->str(1)); int m = stoi(it->str(2)); int x = round((8 - stof(it->str(3))) * 60); int t = (h * 60 + m + x + 1440) % 1440; res.emplace_back(t / 60, t % 60); } for (int i = 0; i < res.size(); ++i) { printf( "%02d:%02d%c", res[i].first, res[i].second, " \n"[i + 1 == res.size()] ); } if (res.empty()) puts(""); } ``` [我想要下班](https://pc2.tfcis.org/dev/index.php/problem/view/85/) --- first blood: **wanling1212** KMP/Z/Hashing [惠惠的おっぱい魔法](https://pc2.tfcis.org/dev/index.php/problem/view/63/) --- first blood: **emanlaicepsa** (出題者說他明天再講) [省油錢](https://pc2.tfcis.org/dev/index.php/problem/view/94/) --- first blood: **Elliot** KMP 最小循環節 len = |S| - |S 的最長共同前後綴| 檢查是否 len 整除 |S| [EXPLOSION](https://pc2.tfcis.org/dev/index.php/problem/view/52/) --- first blood: X 可以很輕易地確認,從$(x_1,y_1)$到$(x_2,y_2)$的整數點會有$\gcd(x_2-x_1,y_2-y_1)+1$。 先把所有的點(包含相交的部份)算進來,再枚舉兩線段相交,相交則須扣除重複的點,可以在對點$i$枚舉時把相交的點丟進`set`裡,最後枚舉完點$i$時扣除`set`的`size`。 時間:$O(n^2\log n)$ [Simple DP Problem](https://pc2.tfcis.org/dev/index.php/problem/view/79/) --- First blood: **zaneyu** 使用講義程式碼的作法 ```cpp int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; ExpandableHull<long long> H; long long dp = 0; for (int i = 0; i < n; ++i) { int a, b; cin >> a >> b; H.addLine(Linear<long long>(b, dp)); dp = H(a); } cout << dp << '\n'; } ``` [Weight on Suffix](https://pc2.tfcis.org/dev/index.php/problem/view/77/) --- first blood: X 用 SA 找出相對應的後綴們,會得到在 SA 上的一個區間,對該區間做 RMQ [Intersection of Lines on Integer Points](https://pc2.tfcis.org/dev/index.php/problem/view/92/) --- first blood: **ToMmyDong** 把提供的 Line 模板找尋相交改為測試 (x, y) 座標的整數是否除盡即可 [十字騎士與危險的陷阱](https://pc2.tfcis.org/dev/index.php/problem/view/54/) --- first blood: **wanling1212** 對字串$S$做KMP failure(next數組) build,然後定義DP: $$ DP[i] = S[0\dots i]\text{出現在}S\text{自身的次數} $$ 已知所有$DP[i]$至少出現一次($S[0\dots i]$自身),預先設$DP[i]=1$。 當$next[i]\neq-1$時,$DP[next[i]]+=DP[i]$。因為所有出現在$S$中的$S[0\dots i]$字串一共有$DP[i]$個,其中這$DP[i]$個字串的後綴皆包含$S[0\dots next[i]]$。 在此DP轉移的基礎下,由$i=\text{strlen}(S)-1$開始處理至0後,把DP加總即可。 時間:$O(n)$ [靜態凸包搜尋](https://pc2.tfcis.org/dev/index.php/problem/view/80/) --- First blood: **ToMmyDong** 使用講義程式碼的作法 ```cpp int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<Linear<long long>> UL, LL; for (int i = 0; i < n; ++i) { int a, b; cin >> a >> b; UL.push_back(Linear<long long>(a, b)); LL.push_back(Linear<long long>(-a, -b)); } ConvexHull<long long> U(UL), L(LL); while (m--) { int x; cin >> x; cout << U(x) + L(x) << '\n'; } } ```

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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