Task: | Ruudukko |
Sender: | andreibe |
Submission time: | 2022-10-31 12:51:24 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 28 |
#2 | ACCEPTED | 33 |
#3 | ACCEPTED | 39 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#4 | ACCEPTED | 0.01 s | 2, 3 | details |
#5 | ACCEPTED | 0.01 s | 2, 3 | details |
#6 | ACCEPTED | 0.01 s | 2, 3 | details |
#7 | ACCEPTED | 0.20 s | 3 | details |
#8 | ACCEPTED | 0.27 s | 3 | details |
#9 | ACCEPTED | 0.41 s | 3 | details |
Compiler report
input/code.cpp: In function 'bool compare(lol&, lol&)': input/code.cpp:18:24: warning: self-comparison always evaluates to false [-Wtautological-compare] 18 | return a.x < a.x; | ~~~ ^ ~~~
Code
#include <iostream> #include <string> #include <math.h> #include <vector> #include <algorithm> using namespace std; typedef long long ll; struct lol { int value; int y; int x; }; int M = 1000000007; bool compare(lol &a, lol &b) { if (a.value == b.value) { if (a.y == b.y) { return a.x < a.x; } return a.y < b.y; } return a.value < b.value; } ll d[1010][1010]; ll rivit[1010]; ll kolumnit[1010]; int main() { cin.tie(0); iostream::sync_with_stdio(0); int n; cin >> n; vector<lol> v; v.reserve(n*n); for (int y = 0; y < n; y++) { for (int x = 0; x < n; x++) { int val; cin >> val; v.push_back({val,y,x}); } } sort(v.begin(),v.end(),compare); int curnumber = v[0].value; vector<lol> toedit; ll sum = 0; for (lol &pair : v) { if (pair.value != curnumber) { for (lol p : toedit) { rivit[p.y] += d[p.y][p.x]; rivit[p.y] %= M; kolumnit[p.x] += d[p.y][p.x]; kolumnit[p.x] %= M; } toedit.clear(); curnumber = pair.value; } int y = pair.y; int x = pair.x; d[y][x] += rivit[y] + kolumnit[x] + 1; d[y][x] %= M; sum += d[y][x]; sum %= M; toedit.push_back(pair); } cout << sum; }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
3 1 1 1 1 1 1 1 1 1 |
correct output |
---|
9 |
user output |
---|
9 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
3 1 2 3 6 5 4 7 8 9 |
correct output |
---|
135 |
user output |
---|
135 |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
3 7 8 1 4 5 4 3 9 6 |
correct output |
---|
57 |
user output |
---|
57 |
Test 4
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
10000 |
user output |
---|
10000 |
Test 5
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
187458477 |
user output |
---|
187458477 |
Test 6
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 2995 8734 1018 2513 7971 5063 ... |
correct output |
---|
964692694 |
user output |
---|
964692694 |
Test 7
Group: 3
Verdict: ACCEPTED
input |
---|
1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
1000000 |
user output |
---|
1000000 |
Test 8
Group: 3
Verdict: ACCEPTED
input |
---|
1000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
229147081 |
user output |
---|
229147081 |
Test 9
Group: 3
Verdict: ACCEPTED
input |
---|
1000 520283 805991 492643 75254 527... |
correct output |
---|
951147313 |
user output |
---|
951147313 |