QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#197819#6964. WerewolvesPPP#AC ✓2ms3456kbC++171.2kb2023-10-02 20:19:372023-10-02 20:19:38

Judging History

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

  • [2023-10-02 20:19:38]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3456kb
  • [2023-10-02 20:19:37]
  • 提交

answer

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define X first
#define Y second

const ll mod = 1000000007;

void solve()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> A;
    vector<ll> a(n-1,0);
    ll S = 0;
    while (true)
    {
        A.push_back(S%m);
        int ok = 0;
        for (ll j=n-2;j>=0;j--)
        {
            if (a[j]!=m-1)
            {
                a[j]++;
                S++;
                for (ll w=j+1;w<n-1;w++)
                {
                    S -= a[w];
                    a[w] = a[j];
                    S += a[j];
                }
                ok = 1;
                break;
            }
        }
        if (ok==0) break;
    }
    for (ll i=0;i<n;i++)
    {
        for (ll j=0;j<A.size();j++)
        {
            ll x = (i+m-A[j])%m;
            cout << x+1 << " ";
        }
        cout << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//#ifdef DEBUG
//    freopen("input.txt", "r", stdin);
//#endif
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3456kb

input:

45
5 3
7 3
14 2
8 3
9 4
6 3
4 4
7 2
11 2
12 2
7 5
9 5
9 2
5 2
19 2
16 2
6 2
6 4
2 2
12 3
5 5
10 2
8 6
18 2
7 6
13 3
10 3
8 5
17 2
10 4
8 2
11 3
15 2
8 4
4 2
6 6
9 3
20 2
13 2
5 4
7 7
7 4
3 3
21 2
6 5

output:

1 3 2 2 1 3 1 3 2 1 3 2 1 3 2 
2 1 3 3 2 1 2 1 3 2 1 3 2 1 3 
3 2 1 1 3 2 3 2 1 3 2 1 3 2 1 
1 3 2 2 1 3 1 3 2 1 3 2 1 3 2 
2 1 3 3 2 1 2 1 3 2 1 3 2 1 3 
1 3 2 2 1 3 1 3 2 1 3 2 1 3 2 2 1 3 2 1 3 1 3 2 1 3 2 1 
2 1 3 3 2 1 2 1 3 2 1 3 2 1 3 3 2 1 3 2 1 2 1 3 2 1 3 2 
3 2 1 1 3 2 3 2 1 3 2 1 3 2 1 1...

result:

ok