Submission details
Task:Monikulmio
Sender:sandyy
Submission time:2025-11-05 19:11:33 +0200
Language:C++ (C++17)
Status:READY
Result:97
Feedback
groupverdictscore
#1ACCEPTED97
Test results
testverdicttimescore
#1ACCEPTED0.00 s10details
#2ACCEPTED0.00 s10details
#3ACCEPTED0.00 s10details
#4ACCEPTED0.00 s10details
#5ACCEPTED0.00 s10details
#6ACCEPTED0.00 s10details
#7ACCEPTED0.00 s10details
#8ACCEPTED0.00 s10details
#9ACCEPTED0.00 s10details
#10ACCEPTED0.01 s7details

Compiler report

input/code.cpp: In function 'void setIO(std::string)':
input/code.cpp:6:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |                 freopen((name+".in").c_str(), "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cpp:7:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |                 freopen((name+".out").c_str(), "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cpp: In function 'void solve()':
input/code.cpp:96:33: warning: 'c2.std::array<int, 2>::_M_elems[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   96 |                                 if(c2[1]<c1[1]) swap(c1, c2);
      |                                 ^~
input/code.cpp:94:33: warning: 'c2.std::array<int...

Code

#include<bits/stdc++.h>
using namespace std;
 
void setIO(string name="") {
	if(name.length()) {
		freopen((name+".in").c_str(), "r", stdin);
		freopen((name+".out").c_str(), "w", stdout);
	}
}
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << "\n"
#define ar array
#define fi first
#define se second
 
const int mxN=105;
int n, m, c, cnt[mxN][mxN];
char grid[mxN][mxN];
 
void solve() {
	cin >> n >> m >> c;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			grid[i][j]='.';
		}
	}
	vector<ar<int, 2>> corners(c);
	for(int i=0; i<c; i++) {
		cin >> corners[i][0] >> corners[i][1];
		grid[corners[i][0]][corners[i][1]]='*';
	}
	for(int k=0; k<c; k++) {
		int a = k-1;
		int b = k;
		if(k==0) a = c-1;
		if(corners[a][1]==corners[b][1]) {
			for(int i=min(corners[a][0], corners[b][0])+1; i<max(corners[a][0], corners[b][0]); i++) {
				grid[i][corners[a][1]]='|';
			}
		}
		if(corners[a][0]==corners[b][0]) {
			for(int i=min(corners[a][1], corners[b][1])+1; i<max(corners[b][1], corners[a][1]); i++) {
				grid[corners[a][0]][i]='=';
			}
		}
		if(corners[a][0]!=corners[b][0] && corners[a][1]!=corners[b][1]) {
			if(corners[a][1]>corners[b][1]) swap(a, b);
			if(corners[a][0] > corners[b][0]) {
				for(int i=1; i<=abs(corners[b][1]-corners[a][1])-1; i++) {
					grid[corners[a][0]-i][corners[a][1]+i]='/';
				}
			} else {
				for(int i=1; i<=corners[b][1]-corners[a][1]-1; i++) {
					grid[corners[a][0]+i][corners[a][1]+i]='\\';
				}
			}
		}
	}
	// every time you encounter a vertex, search for it and look at the vertices it is connected to
	// treat horizontal edges the same way
	// if there is one edge going above and one below, treat it as one
	// otherwise do not increment cnt
	for(int i=1; i<=n; i++) {
		int above=0, below=0;
		for(int j=1; j<=m; j++) {
			cnt[i][j]=cnt[i][j-1];
			if(grid[i][j]=='|' || grid[i][j]=='/' || grid[i][j]=='\\') cnt[i][j]++;
			if(grid[i][j]=='*') {
				ar<int, 2> c1, c2;
				for(int k=0; k<c; k++) {
					if(corners[k][0]==i && corners[k][1]==j) {
						if(k==0) {
							c1=corners[c-1];
							c2=corners[k+1];
						} else if(k==c-1) {
							c1=corners[k-1];
							c2=corners[0];
						} else {
							c1=corners[k-1];
							c2=corners[k+1];
						}
						break;
					}
				}
				// let c1 be above the current vertex
				if(c1[0]<c2[0]) swap(c1, c2);
				// let c1 be on the left of the current vertex
				if(c2[1]<c1[1]) swap(c1, c2);
				if(c1[0]==i && c2[0]==i) continue; // still the same edge
				// if they are on different sides of the line
				if((c1[0]<i && c2[0]>i) || (c1[0]>i&&c2[0]<i)) cnt[i][j]++;
				if(c1[0]!=i && c2[0]==i) {
					cnt[i][j]++;
					if(c1[0]>i) below++;
					else above++;
				}
				if(c1[0]==i && c2[0]!=i) {
					if(c2[0]>i) {
						below++;
					} else {
						above++;
					}
					if(below!=above) {
						cnt[i][j]++;
						below=0, above=0;
					} else {
						below=0, above=0;
					}
				}
			}
			//cout << cnt[i][j] << " ";
		}
		//cout << "\n";
	}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			if(grid[i][j]=='.') {
				if(cnt[i][j]&1) {
					cout << '#';
				} else cout << grid[i][j];
			} else cout << grid[i][j];
		}
		cout << "\n";
	}
}
 
int main() {
	cin.tie(0) -> sync_with_stdio(0);
	//setIO("sleepy");
	int T=1;
	//cin >> T;
	while(T--)
		solve();
	return 0;
}

Test details

Test 1 (public)

Verdict: ACCEPTED

input
8 9 5
5 2
2 5
5 8
7 8
...

correct output
.........
....*....
.../#\...
../###\..
.*#####*.
...

user output
.........
....*....
.../#\...
../###\..
.*#####*.
...

Test 2 (public)

Verdict: ACCEPTED

input
20 40 4
5 10
5 30
15 30
15 10

correct output
.................................

user output
.................................

Test 3 (public)

Verdict: ACCEPTED

input
20 40 29
8 7
13 2
14 2
9 7
...

correct output
.................................

user output
.................................

Test 4 (public)

Verdict: ACCEPTED

input
20 40 14
5 12
5 25
8 28
13 28
...

correct output
.................................

user output
.................................

Test 5 (public)

Verdict: ACCEPTED

input
20 40 12
3 20
7 16
7 9
11 13
...

correct output
.................................

user output
.................................

Test 6 (public)

Verdict: ACCEPTED

input
9 35 33
2 3
2 8
4 8
4 5
...

correct output
.................................

user output
.................................

Test 7 (public)

Verdict: ACCEPTED

input
30 100 69
6 10
6 14
7 14
7 18
...

correct output
.................................

user output
.................................

Test 8 (public)

Verdict: ACCEPTED

input
40 60 192
11 3
11 5
10 6
11 7
...

correct output
.................................

user output
.................................

Test 9 (public)

Verdict: ACCEPTED

input
50 100 142
1 1
1 7
1 11
1 14
...

correct output
*=====*===*==*...................

user output
*=====*===*==*...................

Test 10 (public)

Verdict: ACCEPTED

input
100 100 1000
10 1
4 7
1 4
1 9
...

correct output
...*====*........................

user output
...*====*........................

Feedback: Lines are drawn correctly. Incorrect fill character on row 4, col 36: expected '.', got '#'