QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#145208#6743. water235berarchegas#WA 8ms50524kbC++171.5kb2023-08-22 00:42:172023-08-22 00:42:20

Judging History

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

  • [2023-08-22 00:42:20]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:50524kb
  • [2023-08-22 00:42:17]
  • 提交

answer

#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
 
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());
    
const int maxn = 1000010;

const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
const ll INF = 2e18;

int n, m;

vector<int> v[maxn];
vector<int> aux[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    bool transposed = false;

    if( n > m )
        swap( n , m ), transposed = true;

    for(int i = 0 ; i < n ; i++)    
        v[i].resize( m );

    int p = 0;
    int ans = 0;

    while( p + n <= m )
    {
        for(int i = 0 ; i < n ; i++)
            v[i][p++] = 1, ans++;

        p++;
    }

    p--;
    int line = max( n - 2 , 0 );

    while( p < m )
        v[line][p] = 1, ans++, line = max(0, line - 1), p++;

    if( transposed )
    {
        for(int i = 0 ; i < m ; i++)
            aux[i].resize( n );

        for(int i = 0 ; i < n ; i++)
            for(int j = 0 ; j < m ; j++)    
                aux[j][i] = v[i][j];

        swap( n , m );

        for(int i = 0 ; i < n ; i++)
            v[i].resize( m );

        for(int i = 0 ; i < n ; i++)
            for(int j = 0 ; j < m ; j++)    
                v[i][j] = aux[i][j];
    }

    cout << ans << endl;

    for(int i = 0 ; i < n ; i++, cout << endl)
        for(int j = 0 ; j < m ; j++)
            cout << v[i][j] << " ";
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 50372kb

input:

2 1

output:

2
1 
1 

result:

ok The answer is correct.

Test #2:

score: 0
Accepted
time: 7ms
memory: 50348kb

input:

3 3

output:

3
1 0 0 
0 1 0 
0 0 1 

result:

ok The answer is correct.

Test #3:

score: 0
Accepted
time: 8ms
memory: 50348kb

input:

1 4

output:

3
1 0 1 1 

result:

ok The answer is correct.

Test #4:

score: 0
Accepted
time: 7ms
memory: 50524kb

input:

2 2

output:

2
1 0 
0 1 

result:

ok The answer is correct.

Test #5:

score: -100
Wrong Answer
time: 5ms
memory: 50516kb

input:

2 4

output:

4
1 0 1 1 
0 1 0 0 

result:

wrong answer The answer is wrong: expected = 3, found = 4