답안 #679464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
679464 2023-01-08T10:35:28 Z koolaider Kaučuk (COCI21_kaucuk) C++17
10 / 50
1 ms 300 KB
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;

void setIO(string s) {
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}


#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define pb push_back
#define ll long long

const int MN = 2e9;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



/*
#pragma GCC target ("avx,avx2")
#pragma GCC optimize ("Ofast")
*/

//const long long ML = 1e18;
//const int MN = 1e9;


int main(int argc, char **argv){
	//ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL);	
	//setIO("evolution");
	int n; cin >> n; string a, b;
	string arr[3][n]; 
	for(int i = 0; i<3; i++){
		for(int j = 0; j<n; j++){
			arr[i][j]="x";
			}
		}
	
	
	for(int i = 0; i<n; i++){
		cin >> a >> b;
		if(a=="section"){
		arr[0][i]=b;
		}else if(a=="subsection"){
		arr[1][i]=b;
		}else{
		arr[2][i]=b;
		}
		}
	int x=0, y=0, z=0;
	for(int i = 0; i<n; i++){
		string temp = "x";
		if(arr[0][i]!="x"){
		x++; y=0; z=0; temp = arr[0][i];
		}else if(arr[1][i]!="x"){
		y++; z=0; temp = arr[1][i];
		}else if(arr[2][i]!="x"){
		z++; temp = arr[2][i];
		}
		if(temp!="x"){
		if(x!=0){
			cout << x;
		if(y!=0){
			cout << '.' << y;
			if(z!=0){
			cout << '.' << z << " ";
				}else{
					cout << " ";
					}
			}else{
				cout << " ";
				}
		}
		cout << temp << endl;
		}
		}	
	
			
	return 0;
}





//g++ -std=c++17 -Wshadow -Wall -o "%e" "%f" -O2 -Wno-unused-result

//g++ -std=c++17 -Wshadow -Wall -o "%e" "%f" -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG

Compilation message

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:7:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  freopen((s + ".in").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  freopen((s + ".out").c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -