HankLee0909
    • 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

      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
    • Note Insights
    • 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 Note Insights 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

    This note has no invitees

  • 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
    ### g596. 2. 動線安排 ###### 2021年11月 ### 以題目下方得圖片進行場地設置 ###### #以@代替木樁 以*當作線 以_代表無 ```python= def change(sr,sc,maze,flag):#定義變化函式(無論是加入木樁還是移除木樁)(sr,sc:木樁位置,maze:場地,flag:判斷加入還是移除=題目的t) for cr,cc in [(0,-1),(0,1),(-1,0),(1,0)]:#判斷上下左右有沒有木樁"@" nr,nc=sr+cr,sc+cc while 0<=nr<row and 0<=nc<col and not(maze[nr][nc]=="@"):#如果超出邊界,停止while-loop避免index out of range nr,nc=nr+cr,nc+cc if 0<=nr<row and 0<=nc<col:#沒有超出邊界,代表存在"@" if cr==0:#r的改變值=0,代表改變的是c for c in range(min(nc,sc)+1,max(nc,sc)): if flag:#刪除線時要注意:如果拔掉木樁,但如果仍有其他木樁連線,不能刪掉 if not("@" in [maze[a][c] for a in range(sr)] and "@" in [maze[a][c] for a in range(sr+1,row)]):#檢測針對每個col值,將上下的值加到陣列,檢測是否兩邊都有"@",如果符合,就不刪除 maze[sr][c]="_" #刪除線轉成無 else: maze[sr][c]="*"#加入線 else:#r值改變 for r in range(min(nr,sr)+1,max(nr,sr)): if flag:#原理類似 if not("@" in maze[r][:sc] and "@" in maze[r][sc+1::]): maze[r][sc]="_" else: maze[r][sc]="*" if flag:maze[sr][sc]="_"#移除"@" else:maze[sr][sc]="@"#加入"@" return maze,row*col-sum([item.count("_") for item in maze]) row,col,n=map(int,input().split()) ans=0#紀錄最大值 maze=[["_"]*col for _ in range(row)]#初始化場地 for _ in range(n): r,c,t=list(map(int,input().split())) maze,now=change(r,c,maze,t) ans=max(ans,now)#ans和now比較,如果now比較大就變成now print(ans) print(now) ``` ### 以數字代表不同含意 ###### #0:無 1:木樁 4:橫線 5:直線 9(4+5):橫線+直線 ```python= def change(sr,sc,maze,flag):#定義變化函式(無論是加入木樁還是移除木樁)(sr,sc:木樁位置,maze:場地,flag:判斷加入還是移除=題目的t) for cr,cc in [(0,-1),(0,1),(-1,0),(1,0)]:#判斷上下左右有沒有0 nr,nc=sr+cr,sc+cc while 0<=nr<row and 0<=nc<col and not(maze[nr][nc]==1):#如果超出邊界,停止while-loop避免index out of range nr,nc=nr+cr,nc+cc if 0<=nr<row and 0<=nc<col:#沒有超出邊界,代表存在有0 if cr==0:#r的改變值=0,代表改變的是c(橫線) for c in range(min(nc,sc)+1,max(nc,sc)): if flag: maze[sr][c]=max(0,maze[sr][c]-4) #防止刪除沒有線的地方,產生負值 else: if not(maze[sr][c] in (4,9)):#防止增加已經有橫線的地方,產生8或其他 maze[sr][c]+=(4) else:#r值改變(直線) for r in range(min(nr,sr)+1,max(nr,sr)): if flag: maze[r][sc]=max(0,maze[r][sc]-5) #防止刪除沒有線的地方,產生負值, else: if not(maze[r][sc] in (5,9)):#防止增加已經有直線的地方,產生10或其他 maze[r][sc]+=(5) if flag:maze[sr][sc]=0#移除0 else:maze[sr][sc]=1#添加1 return maze,row*col-sum([item.count(0) for item in maze]) row,col,n=map(int,input().split()) ans=0#紀錄最大值 maze=[[0]*col for _ in range(row)]#初始化場地 for _ in range(n): r,c,t=list(map(int,input().split())) maze,now=change(r,c,maze,t) ans=max(ans,now)#ans和now比較,如果now比較大就變成now print(ans) print(now) ```

    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