답안 #473799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473799 2021-09-16T09:20:07 Z SaraMostafa Crtanje (COCI20_crtanje) C++14
30 / 50
2 ms 460 KB
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define endl "\n"
#define Sara ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod=1e9+7;
const double PI=acos(-1);
// 1 2 3 --> 1,2,3 ...1,2..1,3..1..2,3..2..3..none (2 power number of elements)
//1 2 3 --> 2--> 1,2..1,3..2,3..(!n/(r!(n-r)!)) aka:ncr
// 1 2 3 -->2-->1,2..2,1..1,3..3,1..2,3..3,2..(n!/(n-r)!) aka:npr
//1 2 3--> 1..1,2..1,2,3..2..2,3..3  number of subarrays -->(n*(n+1))/2 "sum of numbers from 1 to n."
/*
ll power(ll x,ll y)
{
    if(y==0)
        return 1;
    else if(y==1)
        return x%mod;
    ll  r=power(x%mod,((y%mod)/2)%mod);
    if(y%2==0)
        return ((r%mod)*(r%mod));
    else
        return ((r%mod)*(r%mod)*(x%mod));
}

ll inverse(ll md,ll x)
{
    return power(x%mod,mod-2);
}

*/

int main()
{
    //freopen("input.in","r",stdin);

    Sara
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<vector<char>>v(1000,vector<char>(n));
    ll now=500;
    bool up=0,down=0,st=0;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='+')
        {
            if(up) now--;
            v[now][i]='/';
            up=1;
            down=0;
            st=0;

        }
        if(s[i]=='-'){
           if(down) now++;
            v[now][i]='\\';
            down=1;
            up=0;
            st=0;

        }
        if(s[i]=='='){
                if(up) now--;
            v[now][i]='_';
            up=0;
            down=0;

        }
    }
    vector<string>d;
    for(int i=0;i<1000;i++){
            string te="";
        for(int j=0;j<n;j++){
          te+=v[i][j];
        }
    if(te.find('/') !=-1 || te.find('_')!=-1 || te.find('\\')!=-1) d.push_back(te);
    }
    for(int i=0;i<d.size();i++) {
        for(int j=0;j<n;j++){
            if(d[i][j]!='/' && d[i][j]!='\\' && d[i][j]!='_') d[i][j]='.';
            cout<<d[i][j];
        }
        cout<<endl;
    }

    return 0;
}

Compilation message

crtanje.cpp: In function 'int main()':
crtanje.cpp:79:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |     if(te.find('/') !=-1 || te.find('_')!=-1 || te.find('\\')!=-1) d.push_back(te);
      |        ~~~~~~~~~~~~~^~~~
crtanje.cpp:79:41: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |     if(te.find('/') !=-1 || te.find('_')!=-1 || te.find('\\')!=-1) d.push_back(te);
      |                             ~~~~~~~~~~~~^~~~
crtanje.cpp:79:62: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |     if(te.find('/') !=-1 || te.find('_')!=-1 || te.find('\\')!=-1) d.push_back(te);
      |                                                 ~~~~~~~~~~~~~^~~~
crtanje.cpp:81:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for(int i=0;i<d.size();i++) {
      |                 ~^~~~~~~~~
crtanje.cpp:45:22: warning: variable 'st' set but not used [-Wunused-but-set-variable]
   45 |     bool up=0,down=0,st=0;
      |                      ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Incorrect 2 ms 332 KB Output isn't correct
4 Incorrect 1 ms 332 KB Output isn't correct
5 Correct 2 ms 460 KB Output is correct