답안 #854445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854445 2023-09-27T16:40:50 Z vjudge1 Crtanje (COCI20_crtanje) C++17
50 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast,O3,unroll-loops")
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpi vector<pii>
#define vvpi vector<vpi>
#define vb vector<bool>
#define vvb vector<vb>
#define endl "\n"
#define sp << " " <<
#define F(i, s, n) for(int i = s; i < n; i++)
#define pb push_back
#define fi first
#define se second
int mod = 998244353;

int inf = LLONG_MAX >> 3;

int mult(int x, int y) {
    return (x%mod)*(y%mod)%mod;
}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi gr;
    gr.pb(0);
    int last = 0;
    F(i, 0, n) {
        if(s[i] == '=') gr.pb(last);
        if(s[i] == '+') gr.pb(--last);
        if(s[i] == '-') gr.pb(++last);
    }
    int mn = 1, mx = -1;
    F(i, 1, n+1) {
        if(gr[i] < gr[i-1]) {
            mn = min(gr[i] + 1, mn);
            mx = max(gr[i] + 1, mx);
        } else if(gr[i] > gr[i-1]) {
            mx = max(gr[i], mx);
            mn = min(gr[i], mn);
        } else {
            mn = min(gr[i], mn);
            mx = max(gr[i], mx);
        }
    }
    int m = mx - mn + 1;
    vector<string> table(m, string(n, '.'));
    //F(i, 0, n+1) cout << gr[i] << " ";
    //cout << endl;
    //cout << mn sp mx << endl;
    F(i, 1, gr.size()) {
        int y = gr[i] - mn;
        if(gr[i] < gr[i-1]) {
            y = gr[i] - mn + 1;
        }
        if(gr[i] > gr[i-1]) {
            y = gr[i] - mn;
        }
        //cout << y << endl;
        table[y][i-1] = (gr[i] > gr[i-1] ? '\\' : gr[i] < gr[i-1] ? '/' : '_');
    }
    //F(i, 0, n+1) cout << gr[i] - mn << endl; 
    F(i, 0, m) cout << table[i] << endl;
}

void setIO() {
    ios::sync_with_stdio(0); cin.tie(0);
    #ifdef Local
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
}
signed main() {
    setIO();
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

Compilation message

crtanje.cpp: In function 'void solve()':
crtanje.cpp:15:37: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 | #define F(i, s, n) for(int i = s; i < n; i++)
......
   58 |     F(i, 1, gr.size()) {
      |       ~~~~~~~~~~~~~~~                
crtanje.cpp:58:5: note: in expansion of macro 'F'
   58 |     F(i, 1, gr.size()) {
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct