답안 #173211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173211 2020-01-03T15:14:37 Z mosiashvililuka Red-blue table (IZhO19_stones) C++14
17 / 100
5 ms 2296 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,tes,t,n,m,i,j,z,x,mid,ans,pas,zn,zm,pi;
char ch[1009][1009];
pair <int, int> p[1009];
set <pair <int, int> > s;
set <pair <int, int> >::iterator it;
int main(){
    scanf("%d\n",&tes);
    for(t=1; t<=tes; t++){
        scanf("%d %d\n",&n,&m);
        zn=n/2+1;
        zm=m/2+1;
        pas=0;
        for(i=0; i<=n+1; i++) for(j=0; j<=m+1; j++) ch[i][j]='z';
        i=0;j=0;
        for(a=0; a<=m; a++){
            if(m-a>=zm){
                ans=a+n;
                if(pas<ans){
                    c=a;
                    d=n;
                    pas=ans;
                }
            }else{
                z=zm-(m-a);
                x=n-zn;
                if(z!=0) mid=a*x/z; else mid=0;
                ans=a+mid;
                if(pas<ans){
                    c=a;
                    d=mid;
                    pas=ans;
                }
            }
        }
        printf("%d\n",pas);
        a=c;mid=d;
//        cout<<a<<endl;
        if(m-a>=zm){
            for(i=1; i<=n; i++){
                for(j=1; j<=a; j++){
                    if(i<=n-zn) ch[i][j]='+'; else ch[i][j]='-';
                }
            }
            for(i=1; i<=n; i++){
                for(j=1; j<=m; j++){
                    if(ch[i][j]=='-') printf("-"); else printf("+");
                }
                printf("\n");
            }
        }else{
            z=zm-(m-a);
            x=n-zn;
            if(z!=0) mid=a*x/z; else mid=0;
            ans=a+mid;
            s.clear();
            for(i=1; i<=mid; i++) s.insert(make_pair(z,i));
            e=1;
            while(e<=a){
//                cout<<e<<endl;
                pi=0;
                d=x;
                while(d>0&&s.size()>0){
                    it=s.end();it--;
//                    cout<<(*it).first<<" "<<(*it).second<<" "<<e<<endl;
                    ch[(*it).second][e]='+';
                    pi++;
                    p[pi]=(*it);
                    s.erase(it);
                    d--;
                }
                for(i=1; i<=pi; i++) if(p[i].first>1) s.insert(make_pair(p[i].first-1,p[i].second));
                e++;
            }
            for(j=1; j<=a; j++){
                for(i=1; i<=n; i++){
                    if(ch[i][j]=='z') ch[i][j]='-';
                }
            }
            for(i=1; i<=n; i++){
                for(j=1; j<=m; j++){
                    if(ch[i][j]=='-') printf("-"); else printf("+");
                }
                printf("\n");
            }
        }
    }
    return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d\n",&tes);
     ~~~~~^~~~~~~~~~~~~
stones.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d\n",&n,&m);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB in the table A+B is not equal to 46
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 376 KB in the table A+B is not equal to 46
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 2296 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 376 KB in the table A+B is not equal to 46