Mohamed_Rahal's blog

By Mohamed_Rahal, history, 16 months ago, In English

UVA input format is very frustrating to deal with, or that what I see. For example this UVA 825 problem Anyone can help how to deal with this type of input format and other formats like not giving the number of testcases, the input ends by a newline and other things like those ? :)

Tags uva
  • Vote: I like it
  • -3
  • Vote: I do not like it

»
16 months ago, # |
  Vote: I like it 0 Vote: I do not like it

This is really annoying.
Maybe try to do
while(testCases--){ int W, N; cin >> W >> N; while(W--){//and so on} }

  • »
    »
    16 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    And when there are no testcases ?

    • »
      »
      »
      16 months ago, # ^ |
        Vote: I like it +1 Vote: I do not like it
      while(cin >> W >> N){  
        while(W--){  
        //Prccess  
        }
      }
      
      • »
        »
        »
        »
        16 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Thanks for that, and when the input of one line ends by the end of that line please ?

        • »
          »
          »
          »
          »
          16 months ago, # ^ |
          Rev. 2   Vote: I like it +1 Vote: I do not like it

          getline(cin,s) then process the string and take your input from it often when i solve problem on uva and the can't deal with input i search of the problem solution on git hub and see how the accepted solution process the input :)

»
16 months ago, # |
  Vote: I like it +11 Vote: I do not like it

what about while(cin>>x)

  • »
    »
    16 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    In the problem above, the input of one line ends by the end of the line.

    • »
      »
      »
      16 months ago, # ^ |
        Vote: I like it +11 Vote: I do not like it

      may be getline can use for that situation