Submission #340107

# Submission time Handle Problem Language Result Execution time Memory
340107 2020-12-26T22:20:48 Z kkk Red-blue table (IZhO19_stones) C++14
100 / 100
39 ms 3308 KB
#include<iostream>
#include<algorithm>
#define endl '\n'
using namespace std;
long long n,m;
char s[1003][1003],ans2[1002][1002];
bool p=false;
char k;
void sol()
{
    long long i,j,d,a;
    d=(n-1)/2*m;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            ans2[i][j]=k;
        }
    }
    j=0,a=0;
    for(i=0;i<d;i++)
    {
        if(k=='+')ans2[j][i%m]='-';
        else ans2[j][i%m]='+';a++;
        if(2*a>m){j++;a=0;}
    }
 cout<<m+j<<endl;
    if(p)swap(m,n);
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(!p)s[i][j]=ans2[i][j];
            else s[i][j]=ans2[j][i];
        }
    }


    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cout<<s[i][j];
        }cout<<endl;
    }

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

    long long t,i,j;
    cin>>t;
    for(i=0;i<t;i++)
    {
        cin>>n>>m;
        p=false;k='-';
        if(m<=n){swap(n,m);k='+';p=true;}
        sol();
    }



}

Compilation message

stones.cpp: In function 'void sol()':
stones.cpp:24:9: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   24 |         else ans2[j][i%m]='+';a++;
      |         ^~~~
stones.cpp:24:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   24 |         else ans2[j][i%m]='+';a++;
      |                               ^
stones.cpp: In function 'int main()':
stones.cpp:54:19: warning: unused variable 'j' [-Wunused-variable]
   54 |     long long t,i,j;
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory 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 3 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1516 KB Output is correct
2 Correct 36 ms 2668 KB Output is correct
3 Correct 33 ms 2924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1644 KB Output is correct
2 Correct 32 ms 2540 KB Output is correct
3 Correct 29 ms 2284 KB Output is correct
# Verdict Execution time Memory 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 3 ms 492 KB Output is correct
5 Correct 38 ms 1516 KB Output is correct
6 Correct 36 ms 2668 KB Output is correct
7 Correct 33 ms 2924 KB Output is correct
8 Correct 38 ms 1644 KB Output is correct
9 Correct 32 ms 2540 KB Output is correct
10 Correct 29 ms 2284 KB Output is correct
11 Correct 9 ms 620 KB Output is correct
12 Correct 30 ms 2412 KB Output is correct
13 Correct 32 ms 2540 KB Output is correct
14 Correct 24 ms 2156 KB Output is correct
15 Correct 39 ms 3308 KB Output is correct
16 Correct 29 ms 2668 KB Output is correct
17 Correct 13 ms 1772 KB Output is correct