답안 #334594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334594 2020-12-09T14:34:04 Z GioChkhaidze Crtanje (COCI20_crtanje) C++14
40 / 50
1 ms 492 KB
#include <bits/stdc++.h>
 
#define pb push_back
#define F first
#define S second
 
using namespace std;
 
const int N=111;
 
int n,t[N];
string s;
char C[N][N];
 
main () {
  ios::sync_with_stdio(false);
  cin.tie(NULL),cout.tie(NULL);
	cin>>n;
	cin>>s;
	s="@"+s;
	int Tmax=0,Tmin=0;
	for (int i=1; i<=n; i++) {
		if (s[i]=='+') 
			t[i]=t[i-1]+1;
			else
		if (s[i]=='-') 
			t[i]=t[i-1]-1;
				else
		if (s[i]=='=')
			t[i]=t[i-1];
			
		Tmax=max(Tmax,t[i]);
		Tmin=min(Tmin,t[i]);
	}
 
	int ans=0;
	for (int i=Tmax; i>=Tmin; i--) 
		for (int j=1; j<=n; j++) {
			if (s[j]=='=' && s[j-1]=='-' && t[j]==i) C[i][j]='_',ans++;
				else
			if (s[j]=='=' && s[j-1]=='+' && t[j]==i) C[i][j]='_',ans++;
				else
			if (s[j]=='=' && (j==1 || s[j-1]=='=') && t[j]==i) C[i][j]='_',ans++;
				else
			if (s[j]=='+' && t[j-1]==i) C[i][j]='/',ans++;
				else
			if (s[j]=='-' && t[j]==i) C[i][j]=char(92),ans++;	
				else C[i][j]='.';
		}
		
	for (int i=Tmax; i>=Tmin; i--) {
		bool bo=false;
		for (int j=1; j<=n; j++) 
			if (C[i][j]=='/' || C[i][j]==char(92) || C[i][j]=='_') bo=true;
		if (!bo) continue;
		
		for (int j=1; j<=n; j++)
			cout<<C[i][j];
			cout<<"\n";
	}
}

Compilation message

crtanje.cpp:15:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main () {
      |       ^
crtanje.cpp: In function 'int main()':
crtanje.cpp:57:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   57 |   for (int j=1; j<=n; j++)
      |   ^~~
crtanje.cpp:59:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   59 |    cout<<"\n";
      |    ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)