Submission #414909

# Submission time Handle Problem Language Result Execution time Memory
414909 2021-05-31T10:34:41 Z Pro_ktmr None (JOI16_memory2) C++17
100 / 100
1 ms 332 KB
#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);
        }
    }
}

Compilation message

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 time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 292 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct