Submission #172496

# Submission time Handle Problem Language Result Execution time Memory
172496 2020-01-01T18:26:13 Z youssefbou62 Crayfish scrivener (IOI12_scrivener) C++14
12 / 100
1000 ms 5496 KB
#include  <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
//
string s = "" ; 
const int N = 1e5+5; 
vector<int> adj[N] ; 
int cnt = 0 ;
bool isleaf[N] ;
char leter[N] ;   
void Init(){

}
void dfs ( int u , int d ){
	
	if( isleaf [u] ){
		if( d % 2 == 0){
			s.pop_back() ; 
		}

		else{
			s += leter[u] ; 
		}
		return ; 
	}

	for(int v : adj[u]){
		dfs(v,d+1) ; 
	}
}
void UndoCommands(int U)
{
	// cout << "UndoCommands ("<<U<<")"<<endl;
	// for(int i = cnt - U ; i < cnt ; i++ ){
	// 	adj[cnt].pb(i) ;
	// }
	// dfs(cnt,1) ; 
	for(int i  = cnt - 1 ; i >= cnt - U ; i-- ){
		adj[cnt].pb(i) ; 
		dfs(i,0); 
	}
	// cout << s << endl; 
	cnt ++ ; 

}
void TypeLetter(char L){
	s+=L; 
	isleaf[cnt]=1; 
	leter [cnt] = L ; 
	cnt ++ ; 
}

char GetLetter(int P)
{
	// cout << s[P] << endl;
	return s[P] ; 
}



// int main(){
// 	Init();
// 	TypeLetter('a');TypeLetter('b');
// 	GetLetter(1);
// 	TypeLetter('d');
// 	UndoCommands(2);
// 	UndoCommands(1);
// 	GetLetter(2);
// 	TypeLetter('e');
// 	UndoCommands(1);
// 	UndoCommands(5);
// 	TypeLetter('c'); 
// 	GetLetter(2); 
// 	UndoCommands(2); GetLetter(2); 
// 	// TypeLetter('a'); 
// 	// TypeLetter('b') ; 
// 	// TypeLetter('c') ; 
// 	// UndoCommands(3) ;
// 	// TypeLetter('e') ;  
// 	// UndoCommands(2) ;
// 	// UndoCommands(1) ;  
// }

# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2684 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2652 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 4 ms 2728 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 249 ms 5496 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 2936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 2936 KB Time limit exceeded
2 Halted 0 ms 0 KB -