제출 #414909

#제출 시각아이디문제언어결과실행 시간메모리
414909Pro_ktmrMemory 2 (JOI16_memory2)C++17
100 / 100
1 ms332 KiB
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)

#include"Memory2_lib.h"

// int Flip(int I, int J)
// void Answer(int I, int J, int X)

void Solve(int T, int N){
    vector<pair<int,int>> v[50];
    rep(i, N){
        int ret = Flip(2*i, 2*i+1);
        v[ret].pb({2*i, 2*i+1});
    }
    bool flg = true;
    while(flg){
        flg = false;
        rep(i, N){
            if(v[i].size() == 2){
                rep(j, 2){
                    rep(k, 2){
                        int a, b;
                        if(j == 0) a = v[i][0].first;
                        else a = v[i][0].second;
                        if(k == 0) b = v[i][1].first;
                        else b = v[i][1].second;
                        int ret = Flip(a, b);
                        if(ret != i){
                            v[ret].pb({a, b});
                            Answer(v[i][0].first+v[i][0].second-a, v[i][1].first+v[i][1].second-b, i);
                            v[i].clear();
                            flg = true;
                        }
                    }
                    if(flg) break;
                }

                break;
            }
        }
    }
    rep(i, N){
        if(v[i].size() == 1){
            Answer(v[i][0].first, v[i][0].second, i);
        }
    }
}

컴파일 시 표준 에러 (stderr) 메시지

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:8:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    8 | #define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
      |                           ^
memory2.cpp:17:5: note: in expansion of macro 'rep'
   17 |     rep(i, N){
      |     ^~~
memory2.cpp:8:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    8 | #define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
      |                           ^
memory2.cpp:24:9: note: in expansion of macro 'rep'
   24 |         rep(i, N){
      |         ^~~
memory2.cpp:8:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    8 | #define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
      |                           ^
memory2.cpp:26:17: note: in expansion of macro 'rep'
   26 |                 rep(j, 2){
      |                 ^~~
memory2.cpp:8:27: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
    8 | #define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
      |                           ^
memory2.cpp:27:21: note: in expansion of macro 'rep'
   27 |                     rep(k, 2){
      |                     ^~~
memory2.cpp:8:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    8 | #define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
      |                           ^
memory2.cpp:48:5: note: in expansion of macro 'rep'
   48 |     rep(i, N){
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...