USACO Bronze January 2020 Problem 1

I am working on this problem:
My solution to this problem
My code does not seem to give the correct output.
pls help :slight_smile:

We aren’t just going to debug your code for you. What does your code attempt to do? What’s a case on where it fails? What happens? These are all pieces of information we expect you to provide when you ask a question.

(idk how to repost that asking for help post)

1 Like

I am not asking to debug it…For me the code seems correct but doesnt work…i tried checking how the input is processed but still no clue what is gone wrong. If you could what is wrong I could just check and change the code accordingly :slight_smile:

That’s literally asking us to debug your code.

EDIT: I took a quick look at your code, and it seems that you aren’t printing out any newlines (the very essence of this problem). Is this intentional?

1 Like

If you misunderstood me, I am not telling to edit and rewrite my code. I am telling to tell what is wrong with my algorithm. Later I can change the code accordingly.

Debugging != rewriting your code

1 Like


This is my code at least:

// Created by Jesse Choe - Bronze Template

#include <bits/stdc++.h>
using namespace std;

// Type aliases

using ll = long long;
using str = string; 
using vi = vector<int>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using si = set<int>;

// Vector Operations

#define sz (int)(x).size()
#define pb push_back
#define all(x) begin(x), end(x)
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define del(x, i) erase(begin(x)+i)
#define rem(x,i) erase(begin(x), begin(x)+i)

// Pairs

#define mp make_pair
#define sec second
#define fir first

// Sets and Maps

#define ins insert
#define ez erase
#define cnt count

// Math

#define MOD 1e9+7
#define MAX_INT 1e18*9

// Permutation

#define possibilities(x) while(next_permutation(all(x))

// Loops

#define Trav(a,x) for (auto& a: x)
#define For(i,a,b) for (int i = (a); i < (b); ++i)

// Input/Output - s is basically the file name without the ".in" and ".out"

void setIO(string s) {
   ios_base::sync_with_stdio(0); cin.tie(0); 

int main(){

int n, k; cin >> n >> k;

int curLength = 0;
int words = 0;

For(i, 0, n){
   string s; cin >> s;
   if(curLength <= k){
   	if(words != 1){
   		cout << " ";
   	cout << s;
   } else {
     cout << endl << s;
     words = 1;
     curLength = s.length();

Hope this helps!

Whether the issue is with the idea or the implementation, it’s still debugging.


oh ok sorry…i am new to this forum so perhaps I did not tell all the details about how much I have done in this question. I solved the question on my own too :slight_smile: