結果

問題 No.883 ぬりえ
ユーザー kappybarkappybar
提出日時 2020-04-13 21:09:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 742 bytes
コンパイル時間 1,496 ms
コンパイル使用メモリ 171,192 KB
実行使用メモリ 4,668 KB
最終ジャッジ日時 2023-10-26 01:17:25
合計ジャッジ時間 3,847 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 22 ms
4,668 KB
testcase_16 AC 7 ms
4,348 KB
testcase_17 AC 4 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:21:9: warning: 'r' may be used uninitialized [-Wmaybe-uninitialized]
   21 |     int m = p * k + r;
      |         ^
main.cpp:14:9: note: 'r' was declared here
   14 |     int r;
      |         ^

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const ll INF = 1e18;
const int MOD = 1000000007;

int main(){
    int n,k;
    cin >> n >> k;
    int p = n / (k * k);
    int q = n % (k * k);
    int r;
    rep(i,k+1){
        if(i * i >= q){
            r = i;
            break;
        }
    }
    int m = p * k + r;
    vector<vector<char>> ans(m,vector<char>(m,'.'));
    int cnt = 0;
    rep(i,m)rep(j,m){
        if(i/k == j/k && i/k < p) ans[i][j] = '#',cnt ++;
        else if(i/k == j/k && cnt < n) ans[i][j] = '#',cnt ++;
    }
    cout << m << endl;
    rep(i,m){
        rep(j,m) cout << ans[i][j] ;
        cout << endl;
    }
    return 0;
}
0