답안 #337453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337453 2020-12-20T21:34:11 Z scales Red-blue table (IZhO19_stones) C++17
100 / 100
85 ms 9196 KB
#include <bits/stdc++.h>
/*#ifndef LOCAL_RUN
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize("fast-math")
    #pragma GCC target("avx2,tune=native")
#endif*/
////////////////////BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
using namespace std;
long long a[1000][1000];
int main()
{
        ios::sync_with_stdio(false);
        cin.tie(0);
        //freopen("","r",stdin);
        //freopen("","w",stdout);
    long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
   cin>>t;
   for(q=0;q<t;q++)
   {
       cin>>n;
       cin>>m;
       z=0;
       if(n>m)
       {
           z=1;
           swap(m,n);
       }
       kol=n*m-m*(n/2+1);
       kol=kol/(m/2+1);
       cout<<m+kol<<endl;
       for(i=0;i<n;i++)
       {
           for(j=0;j<m;j++)
           {
               a[i][j]=0;
           }
       }
       i=0;
       j=0;
       g=kol*(m/2+1);
       while(g!=0)
       {
           if(a[i][j]==0)
           {
               g--;
               a[i][j]=1;
               i++;
               j++;
               i=i%kol;
               j=j%m;
           }
           else
           {
               j++;
               j=j%m;
           }
       }
       if(z==0)
       {
           for(i=0;i<n;i++)
           {
               for(j=0;j<m;j++)
               {
                   if(a[i][j]==1)
                   {
                       cout<<'+';
                   }
                   else
                   {
                       cout<<'-';
                   }
               }
               cout<<endl;
           }
       }
       else
       {
           for(j=0;j<m;j++)
           {
               for(i=0;i<n;i++)
               {

                       if(a[i][j]==0)
                       {
                           cout<<'+';
                       }
                       else
                       {
                           cout<<'-';
                       }


               }
               cout<<endl;
           }
       }
   }
    return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:17:21: warning: unused variable 'mini' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
      |                     ^~~~
stones.cpp:17:26: warning: unused variable 'x' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
      |                          ^
stones.cpp:17:28: warning: unused variable 'y' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
      |                            ^
stones.cpp:17:36: warning: unused variable 'l' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
      |                                    ^
stones.cpp:17:38: warning: unused variable 'r' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
      |                                      ^
stones.cpp:17:40: warning: unused variable 'k' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
      |                                        ^
stones.cpp:17:46: warning: unused variable 'x1' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
      |                                              ^~
stones.cpp:17:49: warning: unused variable 'tip' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
      |                                                 ^~~
stones.cpp:17:55: warning: unused variable 'maxi' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
      |                                                       ^~~~
stones.cpp:17:62: warning: unused variable 'y1' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,l,r,k,kol,x1,tip,g,maxi,n,y1;
      |                                                              ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 10 ms 364 KB Output is correct
4 Correct 19 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 1772 KB Output is correct
2 Correct 42 ms 7148 KB Output is correct
3 Correct 43 ms 7168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 2028 KB Output is correct
2 Correct 38 ms 6764 KB Output is correct
3 Correct 36 ms 5612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 10 ms 364 KB Output is correct
4 Correct 19 ms 364 KB Output is correct
5 Correct 85 ms 1772 KB Output is correct
6 Correct 42 ms 7148 KB Output is correct
7 Correct 43 ms 7168 KB Output is correct
8 Correct 60 ms 2028 KB Output is correct
9 Correct 38 ms 6764 KB Output is correct
10 Correct 36 ms 5612 KB Output is correct
11 Correct 41 ms 748 KB Output is correct
12 Correct 39 ms 5356 KB Output is correct
13 Correct 42 ms 5120 KB Output is correct
14 Correct 32 ms 3820 KB Output is correct
15 Correct 46 ms 9196 KB Output is correct
16 Correct 36 ms 7404 KB Output is correct
17 Correct 17 ms 4460 KB Output is correct