Submission #105670

# Submission time Handle Problem Language Result Execution time Memory
105670 2019-04-13T19:33:38 Z Leonardo_Paes Sequence (BOI14_sequence) C++11
25 / 100
1000 ms 768 KB
#include <bits/stdc++.h>

using namespace std;

int vet[100100];

int main(){
	
	int k;

	cin >> k;

  int x;

  bool ok=true;

	for(int i=1; i<=k; i++){
		cin >> vet[i];
    x=vet[1];
    if(x!=vet[i]){
      ok=0;
    }
	}

  if(ok==true){
        if(x==0){
      if(k==1){
        cout << 10 << endl;
      }
      else if(k>=2 and k<=11){
        cout << 100 << endl;
      }
        else if(k>=12 and k<=111){
      cout << 1000 << endl;
    }
    else if(k>=112 and k<=1111){
      cout << 10000 << endl;
    }
    else if(k>=1112 and k<=11111){
      cout << 100000 << endl;
    }
    else{
      cout << 1000000 << endl;
    }
    return 0;
    }
    else if(x==9){
      if(k==1){
        cout << 9 << endl;
      }
      else if(k>=2 and k<=11){
        cout << 89 << endl;
      }
      else if(k>=12 and k<=111){
        cout << 889 << endl;
      }
        else if(k>=112 and k<=1111){
      cout << 8889 << endl;
    }
    else if(k>=1112 and k<=11111){
      cout << 88889 << endl;
    }
    else if(k>=11112 and k<=111111){
      cout << 888889 << endl;
    }
    return 0;
    }
    

    if(k==1){
      cout << x << endl;
    }
    else if(k>=2 and k<=10){
      cout << x*10 << endl;
    }
    else if(k>=11 and k<=100){
      cout << x*100 << endl;
    }
    else if(k>=101 and k<=1000){
      cout << x*1000 << endl;
    }
    else if(k>=1001 and k<=10000){
      cout << x*10000 << endl;
    }
    else if(k>=10001 and k<=100000){
      cout << x*100000 << endl;
    }
    return 0;
  }
  else{
    int resp=0x3f3f3f3f;
    for(int w=1; w<=100000; w++){
          bool ok=true;

      for(int j=1; j<=k; j++){

        int i = w+j-1;
        if(i>=1 and i<=9){
          if(i==vet[j]){
            continue;
          }
        }
        if(i>=10 and i<=99){
          if(i%10==vet[j]){
            continue;
          }
          if((i-i%10)/10==vet[j]){
            continue;
          }
        }
        if(i>=100 and i<=999){
          if(i%10==vet[j]){
            continue;
          }
          if((i%100-i%10)/10==vet[j]){
            continue;
          }
          if((i-i%100)/100==vet[j]){
            continue;
          }
        }if(i>=1000){
          if(i%10==vet[j]){
            continue;
          }
          if((i%100-i%10)/10==vet[j]){
            continue;
          }
          if((i%1000-i%100)/100==vet[j]){
            continue;
          }
          if((i-i%1000)/1000==vet[j]){
            continue;
          }
        }
        ok=false;
      }
      if(ok==true){
        resp=min(resp, w);
      }
    }
      cout << resp << endl;

  }
}

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:86:17: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
       cout << x*100000 << endl;
                 ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 403 ms 404 KB Output is correct
3 Correct 114 ms 384 KB Output is correct
4 Correct 100 ms 384 KB Output is correct
5 Correct 9 ms 384 KB Output is correct
6 Correct 13 ms 384 KB Output is correct
7 Correct 75 ms 384 KB Output is correct
8 Correct 747 ms 396 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 879 ms 476 KB Output is correct
11 Correct 861 ms 384 KB Output is correct
12 Correct 107 ms 384 KB Output is correct
13 Correct 157 ms 356 KB Output is correct
14 Correct 989 ms 376 KB Output is correct
15 Execution timed out 1074 ms 256 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 8 ms 256 KB Output is correct
2 Correct 434 ms 400 KB Output is correct
3 Correct 117 ms 384 KB Output is correct
4 Correct 102 ms 504 KB Output is correct
5 Correct 9 ms 384 KB Output is correct
6 Correct 11 ms 384 KB Output is correct
7 Correct 756 ms 504 KB Output is correct
8 Correct 84 ms 384 KB Output is correct
9 Correct 751 ms 476 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Incorrect 860 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 12 ms 640 KB Output is correct
8 Correct 10 ms 512 KB Output is correct
9 Correct 18 ms 768 KB Output is correct
10 Correct 28 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 404 ms 364 KB Output is correct
3 Correct 98 ms 384 KB Output is correct
4 Correct 99 ms 256 KB Output is correct
5 Execution timed out 1083 ms 512 KB Time limit exceeded
6 Halted 0 ms 0 KB -