답안 #377531

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
377531 2021-03-14T09:39:49 Z Vimmer Sateliti (COCI20_satellti) C++14
50 / 110
202 ms 2668 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")

#define N 301
#define NN 1005000
#define PB push_back
#define M ll(1e9 + 7)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define pri(x) cout << x << endl
#define endl '\n'
#define _ << " " <<
#define F first
#define S second

using namespace std;
//using namespace __gnu_pbds;

//typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> oredered_set;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef short int si;

bitset <N> bt[N], nl, cur, cp, pc;

vector <pair <int, int> > vr;

int main()
{
    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//    freopen("1.in", "r", stdin);

    int n, m;

    cin >> n >> m;

    string s[n];

    for (int i = 0; i < n; i++)
        cin >> s[i];

    bool ft = 0;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            if (s[i][j] == '*')
                {
                    bt[i][j] = 1;

                    ft = 1;
                }
        }

    if (!ft)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
                cout << s[i][j];

            cout << endl;
        }

        exit(0);
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            vr.PB({i, j});

    vector <pair <int, int> > nx; nx.clear();

    int u = 0;

    while (sz(vr) > 1 && u < n)
    {
        nx.clear();

        nx.PB(vr[0]);

        cur = bt[(vr[0].F + u) % n];

        cur >>= (vr[0].S);

        pc = bt[(vr[0].F + u) % n];

        pc <<= ((m - vr[0].S) % m);

        cur |= pc;

        for (int t = 1; t < sz(vr); t++)
        {
            bool ft = 0;

            if (vr[t].F == 18 && vr[t].S == 41)
            {
                ft = 1;
            }

            nl = bt[(vr[t].F + u) % n];

//            if (ft)
//            {
//                for (int i = 0; i < N; i++)
//                    cout << nl[i];
//
//                cout << endl;
//
////                exit(0);
//            }

            nl >>= (vr[t].S);

            pc = bt[(vr[t].F + u) % n];

            pc <<= ((m - vr[t].S) % m);

//            if (ft)
//            {
//                for (int i = 0; i < N; i++)
//                    cout << nl[i];
//
//                cout << endl;
//            }

            nl |= pc;

//            if (ft)
//            {
//                for (int i = 0; i < N; i++)
//                    cout << nl[i];
//
//                cout << endl;
//
//                exit(0);
//            }

            cp = (nl ^ cur);

            int ps = cp._Find_next(-1);

            if (ps == N)
            {
                nx.PB(vr[t]);
            }
            else if (cur[ps] == 0)
            {
                nx.clear();

                nx.PB(vr[t]);

                cur = nl;
            }
        }

        u++;

        vr = nx;
    }

    int x = vr[0].F, y = vr[0].S;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
            cout << s[(x + i) % n][(y + j) % m];

        cout << endl;
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:102:18: warning: variable 'ft' set but not used [-Wunused-but-set-variable]
  102 |             bool ft = 0;
      |                  ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 10 ms 1636 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 10 ms 1636 KB Output is correct
12 Correct 135 ms 2656 KB Output is correct
13 Correct 10 ms 1636 KB Output is correct
14 Correct 39 ms 2656 KB Output is correct
15 Correct 10 ms 1636 KB Output is correct
16 Correct 14 ms 2016 KB Output is correct
17 Correct 202 ms 2656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 10 ms 1636 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 10 ms 1636 KB Output is correct
12 Correct 135 ms 2656 KB Output is correct
13 Correct 10 ms 1636 KB Output is correct
14 Correct 39 ms 2656 KB Output is correct
15 Correct 10 ms 1636 KB Output is correct
16 Correct 14 ms 2016 KB Output is correct
17 Correct 202 ms 2656 KB Output is correct
18 Runtime error 10 ms 2668 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -