consolidate all repos to one for archive
This commit is contained in:
BIN
semester_5/aturp/naloga_3/examples/Vaja 3.pdf
Normal file
BIN
semester_5/aturp/naloga_3/examples/Vaja 3.pdf
Normal file
Binary file not shown.
BIN
semester_5/aturp/naloga_3/examples/Vaja 3_predstavitev.pdf
Normal file
BIN
semester_5/aturp/naloga_3/examples/Vaja 3_predstavitev.pdf
Normal file
Binary file not shown.
11
semester_5/aturp/naloga_3/examples/testni_primer0.txt
Normal file
11
semester_5/aturp/naloga_3/examples/testni_primer0.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
10 8 10
|
||||
+ 4 5 4
|
||||
+ 6 8 2
|
||||
+ 3 0 6
|
||||
+ 7 4 4
|
||||
- 1
|
||||
+ 5 1 2
|
||||
- 3
|
||||
+ 4 0 10
|
||||
+ 2 0 4
|
||||
-6
|
@@ -0,0 +1,10 @@
|
||||
8
|
||||
8
|
||||
6
|
||||
6
|
||||
7
|
||||
7
|
||||
8
|
||||
4
|
||||
4
|
||||
7
|
1001
semester_5/aturp/naloga_3/examples/testni_primer1.txt
Normal file
1001
semester_5/aturp/naloga_3/examples/testni_primer1.txt
Normal file
File diff suppressed because it is too large
Load Diff
1000
semester_5/aturp/naloga_3/examples/testni_primer1_resitev.txt
Normal file
1000
semester_5/aturp/naloga_3/examples/testni_primer1_resitev.txt
Normal file
File diff suppressed because it is too large
Load Diff
100001
semester_5/aturp/naloga_3/examples/testni_primer2.txt
Normal file
100001
semester_5/aturp/naloga_3/examples/testni_primer2.txt
Normal file
File diff suppressed because it is too large
Load Diff
100000
semester_5/aturp/naloga_3/examples/testni_primer2_resitev.txt
Normal file
100000
semester_5/aturp/naloga_3/examples/testni_primer2_resitev.txt
Normal file
File diff suppressed because it is too large
Load Diff
1001
semester_5/aturp/naloga_3/examples/testni_primer3.txt
Normal file
1001
semester_5/aturp/naloga_3/examples/testni_primer3.txt
Normal file
File diff suppressed because it is too large
Load Diff
1000
semester_5/aturp/naloga_3/examples/testni_primer3_resitev.txt
Normal file
1000
semester_5/aturp/naloga_3/examples/testni_primer3_resitev.txt
Normal file
File diff suppressed because it is too large
Load Diff
72
semester_5/aturp/naloga_3/main.cpp
Normal file
72
semester_5/aturp/naloga_3/main.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
struct pillow
|
||||
{
|
||||
int x, y, s;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::ifstream in(argv[1]);
|
||||
if (!in.is_open())
|
||||
{
|
||||
std::cout << "Error opening file" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
int N, V, S;
|
||||
in >> N >> V >> S;
|
||||
|
||||
std::vector<std::multiset<int>> columns(S);
|
||||
char c;
|
||||
int row;
|
||||
std::vector<pillow> pillows;
|
||||
pillows.reserve(N);
|
||||
pillow p;
|
||||
int max_fall = 0;
|
||||
|
||||
for (size_t i = 0; i < N; i++)
|
||||
{
|
||||
in >> c;
|
||||
if (c == '+')
|
||||
{
|
||||
in >> p.x >> p.y >> p.s;
|
||||
p.s--;
|
||||
pillows.push_back(p);
|
||||
for (int j = p.y; j <= p.y + p.s; j++)
|
||||
{
|
||||
columns[j].insert(p.x);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
in >> row;
|
||||
pillow p = pillows[row - 1];
|
||||
for (int j = p.y; j <= p.y + p.s; j++)
|
||||
{
|
||||
columns[j].erase(columns[j].find(p.x));
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &i : columns)
|
||||
{
|
||||
auto it = i.begin();
|
||||
if (it == i.end())
|
||||
{
|
||||
max_fall = V;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*it > max_fall)
|
||||
max_fall = *it;
|
||||
}
|
||||
}
|
||||
std::cout << max_fall << std::endl;
|
||||
max_fall = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
31
semester_5/aturp/naloga_3/makefile
Normal file
31
semester_5/aturp/naloga_3/makefile
Normal file
@@ -0,0 +1,31 @@
|
||||
CC=g++
|
||||
|
||||
CFLAGS= -std=c++23
|
||||
|
||||
INCLUDE_DIR= include
|
||||
|
||||
SRC_DIR= src
|
||||
|
||||
# Get all cpp files from src directory
|
||||
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
|
||||
|
||||
all: main run
|
||||
|
||||
main: main.cpp $(SRCS)
|
||||
$(CC) $(CFLAGS) -O3 -I$(INCLUDE_DIR) $(SRCS) main.cpp -o main
|
||||
|
||||
debug: main.cpp $(SRCS)
|
||||
$(CC) $(CFLAGS) -I$(INCLUDE_DIR) $(SRCS) -g main.cpp -o main
|
||||
|
||||
profile: main.cpp $(SRCS)
|
||||
$(CC) $(CFLAGS) main.cpp -g -pg -static-libgcc -o main
|
||||
|
||||
run: main
|
||||
time ./main ./examples/testni_primer2.txt > out.txt
|
||||
diff out.txt ./examples/testni_primer2_resitev.txt
|
||||
|
||||
zip:
|
||||
zip -r main.zip main.cpp $(INCLUDE_DIR) $(SRC_DIR) makefile
|
||||
|
||||
clean:
|
||||
rm main
|
Reference in New Issue
Block a user