Hi,
You can submit the second assignment on vmchecker. You can log in on it using your moodle accounts.
For Java the archive must contain:
- Museum.java
- Schedule2.java
- Readme.txt
Important! The java files must not have any package declaration in it. If it has, then remove it before uploading the archive.
If you need a more complicated structure you can use the method for C/C++ with Java also by providing a custom Makefile.
For C/C++ you need to provide a Makefile with 3 rules:
- build – a rule to build the binary files
- run-p1 – a rule that runs the first problem (schedule2)
- run-p2 – a rule that runs the second problem (museum)
For any problem please post a comment on this post.
Buna ziua,
Am o problema cu vmchecker si nu inteleg ce inseamna. Programul imi merge pe compilator dar nu stiu ce eroare imi da pe vm checker.
Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at Schedule2.main(Schedule2.java:68)
Linia 68:
x = Integer.parseInt(Character.toString(scan.next().charAt(4)));
Never mind, I solved it.
Can you share how you solved it?
I introduced an “if(scan.hasNext())”. On my tests I did not have any blank space after the last task so it was working without it.
I’ve added an archive with two tests, one is the example.
Buna ziua!
Am o problema cu primul exercitiu de la tema. Ati putea sa imi dati un exemplu ca cel pe care il foloseste VMCheker pentru a ne verifica temele?
Problema e ca atunci cand rulez pe exemplele mele, precum si exemplul din tema imi merge bine dar atunci cand il pun pe VMCheker imi da erori cu arrayoutofbounds.
Acesta ar fi unul din exemplele pe care il rulez:
10
task0 5 4 task1 task2 task3 task4
task1 2 2 task5 task6
task2 3 1 task7
task3 3 2 task8 task9
task4 3 0
task5 4 0
task6 4 0
task7 5 0
task8 10 0
task9 11 0
Am incercat sa modific programul sa poata sa ruleze pe indicii pornind de la 0 in loc de 1 ca atunci imi dadea arrayoutofbound -1.
task0, task1, … are the names of the tasks. You should not assume they will always be named taskX where X is a number. ArrayOutOfBound means that you are trying to access an element of the array that is out of the bounds of your array. For example when it gave you ArrayOutOfBound -1 it means that you tried to access element -1 of an array.
So it could be like this?
maria 5 2 gigel ion
gigel 3 1 task1
ion 2 0
task1 2 0
But in this way we can’t find them as quikly as in the previous method
Yes. That’s why the time limit is so big 🙂
How do i know which node is the root? Is it the first task? Because if i change the root the result is different.
Your solution should not make any assumption that a particular node represents a root.
I can’t make it work on vmChecker. I get make: *** [build] Error 2 for al the tests. I’m using Java and I deleted the package declaration.
Nevermind, I did not realise that I was zipping the folder.
Hello,
I cannot make the 2nd problem work on vmchecker although it works on my computer. In Java, should I display the matrix like this?
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
System.out.print(v[i][j]+" ");
}
System.out.println();
}
..or is it another way around.
On vmchecker I get these
Test 1 problema 2 ………. 0/5 – Raspuns gresit -1 vs -1082075153 – 0.664041 secunde
You should output the answer to the specified file (“museum.out”).
Thank you! 😀
A.
Can you help me with a makefile for C++. I tried a couple of versions, but none of them seems to work.
Here is one of them:
all: schedule2 museum
schedule2: schedule2.o
g++ schedule2.cpp -o schedule2
schedule2.o: schedule2.cpp
g++ -c schedule2.cpp
museum: museum.o
g++ museum.cpp -o museum
museum.o: museum.cpp
g++ -c museum.cpp
clean:
rm -f *.o schedule2 museum
Thanks!
I managed to solve this problem.
build: run-p1 run-p2
run-p1: schedule2.o
g++ schedule2.o -o schedule2
schedule2.o: schedule2.cpp
g++ -c schedule2.cpp
run-p2: museum.o
g++ museum.o -o museum
museum.o: museum.cpp
g++ -c museum.cpp
clean:
rm -f *.o run-p1 run-p2
Can you tell me what’s the problem here? On my computer the problems have correct solutions.
Test 0 problema 1 ………. 0/5 – Raspuns gresit 8 vs -1077542946 – 0.072004 secunde
Test 1 problema 1 ………. 0/5 – Raspuns gresit 24 vs -1080961154 – 0.064003 secunde
Test 2 problema 1 ………. 0/5 – Raspuns gresit 52 vs -1080741554 – 0.060003 secunde
[…]
your run-p1 and run-p2 rules should run, not compile the program, try:
run-p1:
./schedule2
and your build rules should build the binary.
And i outputted the answers in the asked files.
I tried to change the makefile, but i don’t know how to do it properly. Can you please show me the full code?
I think this is correct.
build: ./run-p1 ./run-p2
run-p1: schedule2
./schedule2
run-p2: museum
./museum
schedule2: schedule2.o
g++ schedule2.o -o schedule2
schedule2.o: schedule2.cpp
g++ -c schedule2.cpp
museum: museum.o
g++ museum.o -o museum
museum.o: museum.cpp
g++ -c museum.cpp
clean:
rm -f *.o run-p1 run-p2
Almost, the problem with the current approach is that the build rule also runs the resulting executable. (and that’s not what it’s supposed to do, it should simply generate the binary).
Also, the clean rule should remove the resulting binaries, which in these case are named schedule2 and museum.(not run-p1, run-p2)
So, for your makefile, the build and clean rule could simply be something like:
build: schedule2 museum
clean:
rm -f *.o schedule2 museum
Can you please upload the tests 6,8 or 9 for the problem Schedule2? My result is wrong on them.
No.