fork download
  1. #include <bits/stdc++.h>
  2. //#include <bits/extc++.h>
  3.  
  4. using namespace std;
  5. // using namespace __gnu_pbds;
  6.  
  7. #define LSOne(S) ((S) & -(S))
  8.  
  9. #define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
  10. #define RFOR(i, b, a) for (int i = (int)b; i > (int)a; --i)
  11. #define EACH(x, a) for (auto &x : a)
  12.  
  13. #define ll long long
  14. #define ld long double
  15. #define str string
  16. #define vt vector
  17. #define ii pair<int, int>
  18. #define dd pair<double, double>
  19. #define vi vt<int>
  20. #define vii vt<ii>
  21. #define vvi vt<vi>
  22. #define pX first
  23. #define pY second
  24.  
  25. #define MP make_pair
  26. #define PB push_back
  27.  
  28. #define SORT(A) sort(A.begin(), A.end())
  29. #define RSORT(A) sort(A.rbegin(), A.rend())
  30.  
  31. // #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
  32. // #define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
  33.  
  34. #define PI acos(-1)
  35. #define INF 1e9
  36. #define EPS 1e-9
  37. #define MOD 1e9 + 7
  38.  
  39. // STRINGS
  40. bool in(char tofind, char arr[], int nels){
  41. for(int i = 0; i < nels;i++){
  42. char curr = arr[i];
  43. if (curr == tofind) return true;
  44. }
  45. return false;
  46. }
  47.  
  48. bool sortbysec(pair<string,int> &a, pair<string,int> &b){
  49. return a.second > b.second;
  50. }
  51.  
  52.  
  53.  
  54. int main() {
  55. ios::sync_with_stdio(false);
  56. cin.tie(nullptr);
  57.  
  58. int ncases; cin >> ncases;
  59. char in[5];
  60. FOR(i,0,ncases){
  61. scanf("%s", in);
  62. if(strcmp(in,"P=NP") == 0){
  63. cout << "skipped" << endl;
  64. }
  65. else{
  66. cout << in[0] - '0' + in[2] - '0' << endl;
  67. }
  68.  
  69. }
  70.  
  71. // 1.5
  72. // EX 1
  73. /*
  74.   char line[80];
  75.   char out[5000];
  76.  
  77.   while(gets(line) && strncmp(line,".......",7) != 0){
  78.   strcat(out,line);
  79.   strcat(out," ");
  80.   }
  81.   cout << "\n" << out;
  82.   */
  83.  
  84. // EX 2
  85. /*
  86.   char P[100]; char T[100]; gets(P); gets(T); //inputs
  87.   string p; string t; p = P; t = T; //inputs to string
  88.  
  89.   size_t found = p.find(t); // returns index of match
  90.   cout << "Ocurrence in " << found << endl;
  91.   found = p.find(t, found + 1);
  92.   while(found){
  93.   if(found == string::npos) break;
  94.   cout << "Ocurrence in " << found << endl;
  95.   found = p.find(t, found + 1);
  96.   }
  97.   */
  98.  
  99. // EX 3
  100. /*
  101.   char a[] = "patata";
  102.   //a[0] = toupper(a[0]);
  103.   char vowels[] = "aeiou";
  104.   int nels = (sizeof(vowels)-1)/sizeof(vowels[0]);
  105.  
  106.   FOR(i, 0, (sizeof(a)-1)/sizeof(a[0])){
  107.   char cur = a[i];
  108.   if(!in(cur,vowels, nels)){
  109.   cout << cur << " is consonant" << endl;
  110.   }
  111.   else{
  112.   cout << cur << " is vowel" << endl;
  113.   }
  114.   }
  115.   */
  116.  
  117. // EX 4
  118. /*
  119.   char T[200];
  120.   vector<string> tokens;
  121.   while(gets(T) && strcmp(T,"") != 0) {
  122.   for (char* token = strtok(T, " "); token != nullptr; token = strtok(nullptr," ")){
  123.   tokens.emplace_back(token);
  124.   }
  125.   }
  126.  
  127.   sort(tokens.begin(), tokens.end()); // O(N*log(N))
  128.  
  129.   for(int i = 0; i < tokens.size(); i++){
  130.   cout << tokens[i] << endl;
  131.   }
  132.   */
  133.  
  134. // EX 5
  135. /*
  136.   char T[200];
  137.   unordered_map<string,int> umap;
  138.   while(gets(T) && strcmp(T,"") != 0) {
  139.   for (char* token = strtok(T, " "); token != nullptr; token = strtok(nullptr," ")){
  140.   umap[token] += 1;
  141.   }
  142.   }
  143.  
  144.   vector<pair<string,int>> comp(umap.begin(), umap.end());
  145.   sort(comp.begin(),comp.end(), sortbysec);
  146.  
  147.   int max = comp[0].second;
  148.   for(auto x: comp){
  149.   if(x.second == max){
  150.   cout << x.first << ": " << x.second << endl;
  151.   }
  152.   }
  153.   */
  154.  
  155. // EX 6
  156. /*
  157.   char T;
  158.   int npoint = 0;
  159.   bool afterpoints = false;
  160.   int nchars = 0;
  161.  
  162.   while(T = getchar()){
  163.   cout << T;
  164.   if(afterpoints){
  165.   if (T == '\n') break;
  166.   nchars++;
  167.   }
  168.  
  169.   else if(T == '.') {
  170.   npoint += 1;
  171.   if (npoint == 7) afterpoints = true;
  172.   }
  173.  
  174.   }
  175.   cout << nchars << " chars";
  176.   */
  177. }
Success #stdin #stdout 0.01s 5464KB
stdin
4
2+2
1+2
P=NP
0+0
stdout
13
13
13
13