Submission #500240

# Submission time Handle Problem Language Result Execution time Memory
500240 2021-12-30T13:42:21 Z reni Red-blue table (IZhO19_stones) C++14
100 / 100
25 ms 2252 KB
#include<iostream>
#pragma GCC optimize ("-O3")
#define endl '\n'
using namespace std;
char s[1003][1003];
long long br[1003];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long n,m,i,j,t,ans,i2, num=0;
    bool isf;

    cin>>t;

    while(t--)
    {
        cin>>n>>m;
        isf=0;
        if(n<m){swap(n,m); isf=1;}

        ans=0;

        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
            {
                s[i][j]='+';
            }
            br[i]=0;
        }
        num=0;j=1;
        for(i=1;i<=n;i++)
        {
            if(br[i]==m-(m/2+1))break;
                s[i][j]='-';
                br[i]++;num++;
            if(num==(n/2+1)){num=0;ans++;j++;}
            if(i==n)i=0;

        }
        ans+=n;
      
        cout<<ans<<endl;
        if(!isf)
        {
            for(i=1;i<=n;i++)
            {
             for(j=1;j<=m;j++)
            {
                    cout<<s[i][j];
            }  cout<<endl;
        }
        }
        else
        {
            for(i=1;i<=m;i++)
            {
              for(j=1;j<=n;j++)
             {
                    if(s[j][i]=='+')cout<<'-';
                    else cout<<'+';
            } cout<<endl;
        }

        }

    }

}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:13:29: warning: unused variable 'i2' [-Wunused-variable]
   13 |     long long n,m,i,j,t,ans,i2, num=0;
      |                             ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1348 KB Output is correct
2 Correct 21 ms 1988 KB Output is correct
3 Correct 20 ms 1980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1368 KB Output is correct
2 Correct 17 ms 1800 KB Output is correct
3 Correct 18 ms 1580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 24 ms 1348 KB Output is correct
6 Correct 21 ms 1988 KB Output is correct
7 Correct 20 ms 1980 KB Output is correct
8 Correct 21 ms 1368 KB Output is correct
9 Correct 17 ms 1800 KB Output is correct
10 Correct 18 ms 1580 KB Output is correct
11 Correct 6 ms 588 KB Output is correct
12 Correct 25 ms 1860 KB Output is correct
13 Correct 24 ms 1932 KB Output is correct
14 Correct 15 ms 1612 KB Output is correct
15 Correct 21 ms 2252 KB Output is correct
16 Correct 23 ms 1852 KB Output is correct
17 Correct 8 ms 1216 KB Output is correct