#include <bits/stdc++.h>
using namespace std;
map<int, pair<int, int> > memory;
const int M = 300000;
bool onlyAOwner(int l, int r, int id)
{
for (int i = l; i <= r; i++)
{
if (memory.count(i) == 0)
return false;
if (memory[i].first != id)
return false;
}
return true;
}
int main()
{
int n, m, k;
cin >> n >> m >> k;
for (int i = 1; i <= k; i++)
{
int pro, id, l, r, x;
cin >> pro;
switch (pro)
{
case 0:
{
cin >> id >> l >> r >> x;
int j;
for (j = l; j <= r; j++)
{
if (memory.count(j) == 0)
{
memory[j] = make_pair(id, x);
}
else if (memory[j].first == id || memory[j].first >= M)
{
memory[j].first = id;
memory[j].second = x;
}
else
{
break;
}
}
if (j == l)
j = 0;
cout << j - 1 << endl;
break;
}
case 1:
{
cin >> id >> l >> r;
if (onlyAOwner(l, r, id))
{
for (int j = l; j <= r; j++)
{
memory[j].first += M;
}
cout << "OK" << endl;
}
else
{
cout << "FAIL" << endl;
}
break;
}
case 2:
{
cin >> id >> l >> r;
if (onlyAOwner(l, r, id + M))
{
for (int j = l; j <= r; j++)
{
memory[j].first -= M;
}
cout << "OK" << endl;
}
else
{
cout << "FAIL" << endl;
}
break;
}
case 3:
{
cin >> l;
if (memory.count(l) == 0 || memory[l].first >= M)
{
cout << "0 0" << endl;
}
else
{
cout << memory[l].first << " " << memory[l].second << endl;
}
}
}
}
return 0;
}
CCF-202112-4 磁盘文件操作(25分)
最新推荐文章于 2023-05-28 08:05:04 发布