<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        CodeforcesRound#168(Div.2)-A.LightsOut_html/css

        來源:懂視網 責編:小采 時間:2020-11-27 15:57:34
        文檔

        CodeforcesRound#168(Div.2)-A.LightsOut_html/css

        CodeforcesRound#168(Div.2)-A.LightsOut_html/css_WEB-ITnose:Lights Out time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Lenny is playing a game on a 3×3 grid of lights. In the beginning of the game all lights a
        推薦度:
        導讀CodeforcesRound#168(Div.2)-A.LightsOut_html/css_WEB-ITnose:Lights Out time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Lenny is playing a game on a 3×3 grid of lights. In the beginning of the game all lights a

        Lights Out

        time limit per test

        2 seconds

        memory limit per test

        256 megabytes

        input

        standard input

        output

        standard output

        Lenny is playing a game on a 3?×?3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on then it will be switched off, if it was switched off then it will be switched on.

        Lenny has spent some time playing with the grid and by now he has pressed each light a certain number of times. Given the number of times each light is pressed, you have to print the current state of each light.

        Input

        The input consists of three rows. Each row contains three integers each between 0 to 100 inclusive. The j-th number in the i-th row is the number of times the j-th light of the i-th row of the grid is pressed.

        Output

        Print three lines, each containing three characters. The j-th character of the i-th line is "1" if and only if the corresponding light is switched on, otherwise it's "0".

        Sample test(s)

        input

        1 0 00 0 00 0 1

        output

        001010100

        input

        1 0 18 8 82 0 3

        output

        010011100





        題目大意:現有3*3個開關,初始全為開著。切換(開變成關,關變成開)每個開關的時候,與它直接相鄰的四個方向上的開關也會切換,給出每個開關的切換次數,問最后各個開關的狀態。


        解題思路:我們只需要判斷每個開關到最后總共被切換了多少次,直接判斷次數的奇偶即可判斷某個開關最后的狀態。直接遍歷每個開關,但是如果直接在原來的開關次數上加,會影響對后來的計算,所以,我們開了兩個數組,A[][]和B[][],A是輸入的每個開關的切換次數,B是最后每個開關切換的總次數。最后在掃一遍B即可,若B[i][j]是奇數,則狀態為0(關),否則狀態為1(開)。





        AC代碼:

        #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x7fffffffint a[4][4], b[4][4];int main(){ #ifdef sxk freopen("in.txt","r",stdin); #endif int n; for(int i=0; i<3; i++) for(int j=0; j<3; j++) scanf("%d", &a[i][j]); memset(b,0,sizeof(b)); for(int i=0; i<3; i++) for(int j=0; j<3; j++){ if(a[i][j]){ b[i][j] += a[i][j]; if(i > 0) b[i-1][j] += a[i][j]; if(i < 2) b[i+1][j] += a[i][j]; if(j > 0) b[i][j-1] += a[i][j]; if(j < 2) b[i][j+1] += a[i][j]; } } for(int i=0; i<3; i++){ for(int j=0; j<3; j++){ printf("%d", b[i][j]&1^1); } printf("\n"); } return 0;}

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        CodeforcesRound#168(Div.2)-A.LightsOut_html/css

        CodeforcesRound#168(Div.2)-A.LightsOut_html/css_WEB-ITnose:Lights Out time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Lenny is playing a game on a 3×3 grid of lights. In the beginning of the game all lights a
        推薦度:
        標簽: it out codeforcesround#
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲精品无码国产片| 久久大香伊焦在人线免费| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 中文字幕亚洲综合久久菠萝蜜 | 国色精品va在线观看免费视频| 亚洲毛片免费视频| 久久久久噜噜噜亚洲熟女综合| 亚洲av无码片区一区二区三区| 一级午夜免费视频| 成人免费一区二区无码视频| 亚洲AV无码成人精品区天堂| 久久精品国产亚洲AV电影网| 99久久人妻精品免费一区| 国内精品99亚洲免费高清| 爽爽爽爽爽爽爽成人免费观看| 最近中文字幕无免费视频| 亚洲a在线视频视频| 久久免费香蕉视频| 免费观看午夜在线欧差毛片 | 亚洲国产V高清在线观看| 波多野结衣亚洲一级| 8888四色奇米在线观看免费看| 国产日韩成人亚洲丁香婷婷| 手机看片国产免费永久| 亚洲电影在线免费观看| 久久午夜无码免费| 亚洲Av无码一区二区二三区| 国产高清在线免费视频| 在线观看亚洲AV日韩A∨| 4399好看日本在线电影免费| 亚洲好看的理论片电影| 免费视频一区二区| 久久久久亚洲精品美女| 无人影院手机版在线观看免费| 久久久久亚洲Av无码专| 99久久精品免费视频| 亚洲午夜福利在线视频| 国产亚洲av片在线观看18女人| 曰批视频免费40分钟试看天天 | 亚洲一区二区三区丝袜| 久久国产成人精品国产成人亚洲|