How can I improve myself? What should I do if I don't have any idea for the task? Maybe I should solve more problems in archive, but how? Is there any studying plan?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3821 |
3 | Benq | 3736 |
4 | Radewoosh | 3631 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3388 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
How can I improve myself? What should I do if I don't have any idea for the task? Maybe I should solve more problems in archive, but how? Is there any studying plan?
It is my own DEBUG function(class) it works with GNU G++ 17 and higher. Here is code:
class LOG{
public:
//check if type iterable function
template<typename C>
struct is_iterable{
typedef long false_type;
typedef char true_type;
template<class T> static false_type check(...);
template<class T> static true_type check(int,
typename T::const_iterator = C().end());
enum { value = sizeof(check<C>(0)) == sizeof(true_type) };
};
//string print
static void print_value(string starting, string value, string ending = "\n"){
cout << starting<< "\"" << value<< "\"" << ending;
}
//main print function
template<class T>
static void print_value(string starting, T value, string ending = "\n"){
//if iterable than recursevly print ech value
if constexpr (is_iterable<T>::value){
typename T :: iterator it = value.begin();
cout << starting << "{";
while (it != value.end()){
print_value ("", *it, (next(it, 1) == value.end() ? "" : ", "));
it++;
}
cout << "}";
}
else{
// else we probably have char, int, long long, and etc.
cout << starting << value;
}
cout << ending;
}
//pair print
template<class T, class M>
static void print_value(string starting, pair<T, M> value, string ending = "\n"){
cout << starting << "{";
print_value("", value.ff, "");
cout << ", ";
print_value("", value.ss, "");
cout << "}" << ending;
}
//map recursive print
template<class T, class M>
static void print_value(string starting, map<T, M> value, string ending = "\n"){
cout << starting << "{" << endl;
ll cur = 0;
for (pair<T, M> v: value){
print_value (" {", v.ff, ": ");
print_value ("", v.ss, (cur == value.size() - 1 ? "}" : "},"));
cur++;
cout << endl;
}
cout << "}" << ending;
}
//array print
/*
ARRAY PRINT DOES'T WORK CORRECTLY
I HIGHLY RECOMMEND TO NOT USE IT
*/
template<class T>
static void print_value(string starting, vector<size_t> len, T* value, int dim){
if (len.size() == 1){
for (long long i = 0; i < len[0]; i++){
cout << *(value + i) << " ";
}
}
if (len.size() == 2){
for (long long i = 0; i < len[0]; i++){
for (long long j = 0; j < len[1]; j++){
cout << *(*(value + i) + j) << " ";
}
cout << endl;
}
}
if (len.size() == 3){
for (long long i = 0; i < len[0]; i++){
for (long long j = 0; j < len[1]; j++){
for (long long z = 0; z < len[2]; z++){
cout << *(*(*(value + i)+ j) + z) << " ";
}
cout << endl;
}
cout << endl;
}
}
if (len.size() == 4){
for (long long i = 0; i < len[0]; i++){
for (long long j = 0; j < len[1]; j++){
for (long long z = 0; z < len[2]; z++){
for (long long x = 0; x < len[3]; x++){
cout << (*(*(*(value + i) + j) + z) + x) << " ";
}
cout << endl;
}
cout << endl;
}
cout << endl;
}
}
}
};
now the examples:
#include<bits/stdc++.h>
using namespace std;
//----LOG class code---
int main(){
vector<long long> v(5);
for (long long i = 0; i < 5; i++){
cin >> v[i];
}
LOG::print_value ("starting string ", v, " ending string");
}
this is for all types exept arrays(like this: a[5]) now for arrays:
#include<bits/stdc++.h>
using namespace std;
//----LOG class code---
int main(){
long long v[5][3];
for (long long i = 0; i < 5; i++){
for (long long j = 0; i < 3; j++){
cin >> v[i][j];
}
}
LOG::print_value ("starting string ", {5, 3}, a, 0);
// starting string, vector of lengths, variable name, starting dimension index
}
thath's it. Also check my friend account — ShirChoi. He helped me a lot with this. Wish you luck.
Name |
---|