QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#123047#1806. Character GridScarlett_boyAC ✓0ms3496kbC++173.7kb2023-07-11 17:35:482023-07-11 17:35:50

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-11 17:35:50]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3496kb
  • [2023-07-11 17:35:48]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#pragma GCC optimize(3)
#define pb push_back
#define is insert
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define show(x) cerr<<#x<<" : "<<x<<"\n";
mt19937 mt19937random(std::chrono::system_clock::now().time_since_epoch().count());

ll getRandom(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(mt19937random); }

//clock_t startTime;
//
//double getCurrentTime() {
//    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
//}

inline ll read() {
    ll data = 0, w = 1;
    char ch = 0;
    while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
    if (ch == '-') w = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();
    return data * w;
}

ll fastpower(ll base, ll power, ll mo) {
    ll res = 1;
    while (power) {
        if (power & 1)res = res * base % mo;
        power >>= 1;
        base = base * base % mo;
    }
    return res % mo;
}

#define debug(x...)             \
    do {                      \
        cout << #x << " -> ";\
        err(x);               \
    } while (0)

void err() {
    cout << endl;
}

template<class T, class... Ts>
void err(const T &arg, const Ts &... args) {
    cout << arg << ' ';
    err(args...);
}

void pre_work() {
//    freopen("C:\\Users\\ILLUME\\Downloads\\hand_05.txt","r",stdin);
//    freopen("C:\\Users\\ILLUME\\Desktop\\1.txt","w",stdout);
    ios::sync_with_stdio(0), cin.tie(0);
//    startTime=clock();
}

const ll INF = 0x3f3f3f3f;//2147483647;
const ll MOD[2] = {1000000007, 998244353};
const ll base[2] = {131, 13331};
const double pi = acos(-1.0);

const int N = 55, M = N << 1;
const ll mod = MOD[1];


int n;
int a[N][N];
map<pair<int, int>, int> mp;
int walk[2][2] = {{0, 1},
                  {1, 0}};
int b[N];

void solve() {
    n = 13;
    a[1][1] = 1;
    queue<pair<int, int>> q;
    q.push({1, 1});

    while (!q.empty()) {
        auto[x, y]=q.front();
        q.pop();
        for (int k = 0; k < 2; k++) {
            int dx = x + walk[k][0], dy = y + walk[k][1];
            if (dx > 13 || dy > 13 || a[dx][dy])continue;
            while (1) {
                int z = getRandom(1, 26);
                if (a[dx][dy - 1]) {
                    if (mp.count({a[dx][dy - 1], z}))continue;
                }
                if (a[dx - 1][dy]) {
                    if (mp.count({a[dx - 1][dy], z}))continue;
                }
                q.push({dx, dy});
                a[dx][dy] = z;
                if (a[dx][dy - 1]) {
                    mp[{a[dx][dy - 1], z}] = 1;
                }
                if (a[dx - 1][dy]) {
                    mp[{a[dx - 1][dy], z}] = 1;
                }
                break;
            }

        }
    }
    cout << 13 << "\n";
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cout << (char) (a[i][j] - 1 + 'a');
        }
        cout << "\n";
    }

}

signed main() {
    pre_work();
    int _ = 1;
//    cin >> _;
    for (int i = 1; i <= _; i++) {
        solve();
    }
//    cout<<"run time="<<fixed<<setprecision(8)<<getCurrentTime()<<"\n";
    return 0;
}
/*
1 25 6 15 4 16 8 10 16 20 11 6 6
12 5 26 9 20 13 8 22 12 2 22 7 14
22 19 16 10 8 20 14 10 12 11 18 3 14
17 14 7 11 21 16 16 21 6 5 23 26 22
4 3 8 25 1 26 14 20 10 14 25 17 6
19 11 2 26 11 8 17 9 6 13 3 23 22
12 1 17 1 10 18 11 17 2 21 10 20 5
3 13 25 20 24 4 7 26 24 17 15 20 21
12 17 10 3 7 13 16 23 23 21 8 6 25
16 18 7 5 25 2 6 16 1 15 15 21 14
4 1 2 8 13 12 20 17 3 22 24 19 9
9 14 18 26 18 14 15 19 18 9 26 3 9
24 12 18 6 12 21 18 13 19 21 5 15 7
 */

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3496kb

input:



output:

13
aygjbtfokcwck
avsuanisfxjqd
sotpigtdblxnt
zhesnrkaeuuxs
zlyauiuwhjcth
toddlzybbwicc
irewndhqufdmu
lfgyqpowevxzk
kpgcfzezmlaxm
jpvatrrchrzfk
eljomjhzptvcg
ocnlijvbytwoi
oyfhwmypwqvgp

result:

ok accepted